ability to publish types

This commit is contained in:
lingdocs 2021-09-17 16:39:10 -04:00
parent fb3045ceb2
commit f51282a09b
11 changed files with 407 additions and 0 deletions

29
.github/workflows/publish-types.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Publish Types
on:
push:
branches: [ 'master' ]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
env:
LINGDOCS_NPM_TOKEN: ${{ secrets.LINGDOCS_NPM_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- name: Check if version has been updated
id: check
uses: EndBug/version-check@v1
with:
diff-search: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish when version changed
if: steps.check.outputs.changed == 'true'
run: |
npm run build
npm publish

3
dist/types.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import * as AT from "./website/src/types/account-types";
import * as FT from "./website/src/types/functions-types";
export { AT, FT, };

3
dist/types.js vendored Normal file
View File

@ -0,0 +1,3 @@
import * as AT from "./website/src/types/account-types";
import * as FT from "./website/src/types/functions-types";
export { AT, FT, };

View File

@ -0,0 +1,98 @@
export declare type Hash = string & {
__brand: "Hashed String";
};
export declare type UUID = string & {
__brand: "Random Unique UID";
};
export declare type TimeStamp = number & {
__brand: "UNIX Timestamp in milliseconds";
};
export declare type UserDbPassword = string & {
__brand: "password for an individual user couchdb";
};
export declare type WordlistDbName = string & {
__brand: "name for an individual user couchdb";
};
export declare type URLToken = string & {
__brand: "Base 64 URL Token";
};
export declare type EmailVerified = true | Hash | false;
export declare type ActionComplete = {
ok: true;
message: string;
};
export declare type ActionError = {
ok: false;
error: string;
};
export declare type APIResponse = ActionComplete | ActionError | {
ok: true;
user: LingdocsUser;
};
export declare type WoutRJ<T> = Omit<T, "_raw" | "_json">;
export declare type GoogleProfile = WoutRJ<import("passport-google-oauth").Profile> & {
refreshToken: string;
accessToken: string;
};
export declare type GitHubProfile = WoutRJ<import("passport-github2").Profile> & {
accessToken: string;
};
export declare type TwitterProfile = WoutRJ<import("passport-twitter").Profile> & {
token: string;
tokenSecret: string;
};
export declare type ProviderProfile = GoogleProfile | GitHubProfile | TwitterProfile;
export declare type UserLevel = "basic" | "student" | "editor";
export declare type UserTextOptions = Omit<import("@lingdocs/pashto-inflector").Types.TextOptions, "pTextSize">;
export declare type UserTextOptionsRecord = {
lastModified: TimeStamp;
userTextOptions: UserTextOptions;
};
export declare type LingdocsUser = {
userId: UUID;
admin?: boolean;
password?: Hash;
name: string;
email?: string;
emailVerified: EmailVerified;
github?: GitHubProfile;
google?: GoogleProfile;
twitter?: TwitterProfile;
passwordReset?: {
tokenHash: Hash;
requestedOn: TimeStamp;
};
upgradeToStudentRequest?: "waiting" | "denied";
tests: [];
lastLogin: TimeStamp;
lastActive: TimeStamp;
userTextOptionsRecord: undefined | UserTextOptionsRecord;
} & ({
level: "basic";
} | {
level: "student" | "editor";
couchDbPassword: UserDbPassword;
wordlistDbName: WordlistDbName;
}) & import("nano").MaybeDocument;
export declare type CouchDbAuthUser = {
type: "user";
name: UUID;
password: UserDbPassword;
roles: [];
} & import("nano").MaybeDocument;
export declare type UpgradeUserResponse = {
ok: false;
error: "incorrect password";
} | {
ok: true;
message: "user already upgraded" | "user upgraded to student";
user: LingdocsUser;
};
export declare type UpdateUserTextOptionsRecordBody = {
userTextOptionsRecord: UserTextOptionsRecord;
};
export declare type UpdateUserTextOptionsRecordResponse = {
ok: true;
message: "updated userTextOptionsRecord";
user: LingdocsUser;
};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,65 @@
/**
* Copyright (c) 2021 lingdocs.com
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import { Types as T } from "@lingdocs/pashto-inflector";
import * as AT from "./account-types";
export declare type FunctionResponse = PublishDictionaryResponse | SubmissionsResponse | FunctionError;
export declare type FunctionError = {
ok: false;
error: string;
};
export declare type PublishDictionaryResponse = {
ok: true;
info: T.DictionaryInfo;
} | {
ok: false;
errors: T.DictionaryEntryError[];
};
export declare type Submission = Edit | ReviewTask;
export declare type Edit = EntryEdit | NewEntry | EntryDeletion;
export declare type SubmissionBase = {
_id: string;
sTs: number;
user: {
userId: AT.UUID;
name: string;
email: string;
};
};
export declare type ReviewTask = Issue | EditSuggestion | EntrySuggestion;
export declare type EntryEdit = SubmissionBase & {
type: "entry edit";
entry: T.DictionaryEntry;
};
export declare type EntryDeletion = SubmissionBase & {
type: "entry deletion";
ts: number;
};
export declare type NewEntry = SubmissionBase & {
type: "new entry";
entry: T.DictionaryEntry;
};
export declare type Issue = SubmissionBase & {
type: "issue";
content: string;
};
export declare type EditSuggestion = SubmissionBase & {
type: "edit suggestion";
entry: T.DictionaryEntry;
comment: string;
};
export declare type EntrySuggestion = SubmissionBase & {
type: "entry suggestion";
entry: T.DictionaryEntry;
comment: string;
};
export declare type SubmissionsRequest = Submission[];
export declare type SubmissionsResponse = {
ok: true;
message: string;
submissions: Submission[];
};

View File

@ -0,0 +1,8 @@
/**
* Copyright (c) 2021 lingdocs.com
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
export {};

132
package-lock.json generated Normal file
View File

@ -0,0 +1,132 @@
{
"name": "lingdocs-main",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"base64url": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
"integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A=="
},
"fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"optional": true
},
"oauth": {
"version": "0.9.15",
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
"integrity": "sha1-vR/vr2hslrdUda7VGWQS/2DPucE="
},
"passport-github2": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/passport-github2/-/passport-github2-0.1.12.tgz",
"integrity": "sha512-3nPUCc7ttF/3HSP/k9sAXjz3SkGv5Nki84I05kSQPo01Jqq1NzJACgMblCK0fGcv9pKCG/KXU3AJRDGLqHLoIw==",
"requires": {
"passport-oauth2": "1.x.x"
}
},
"passport-google-oauth": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/passport-google-oauth/-/passport-google-oauth-2.0.0.tgz",
"integrity": "sha512-JKxZpBx6wBQXX1/a1s7VmdBgwOugohH+IxCy84aPTZNq/iIPX6u7Mqov1zY7MKRz3niFPol0KJz8zPLBoHKtYA==",
"requires": {
"passport-google-oauth1": "1.x.x",
"passport-google-oauth20": "2.x.x"
}
},
"passport-google-oauth1": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-google-oauth1/-/passport-google-oauth1-1.0.0.tgz",
"integrity": "sha1-r3SoA99R7GRvZqRNgigr5vEI4Mw=",
"requires": {
"passport-oauth1": "1.x.x"
}
},
"passport-google-oauth20": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/passport-google-oauth20/-/passport-google-oauth20-2.0.0.tgz",
"integrity": "sha512-KSk6IJ15RoxuGq7D1UKK/8qKhNfzbLeLrG3gkLZ7p4A6DBCcv7xpyQwuXtWdpyR0+E0mwkpjY1VfPOhxQrKzdQ==",
"requires": {
"passport-oauth2": "1.x.x"
}
},
"passport-oauth1": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/passport-oauth1/-/passport-oauth1-1.2.0.tgz",
"integrity": "sha512-Sv2YWodC6jN12M/OXwmR4BIXeeIHjjbwYTQw4kS6tHK4zYzSEpxBgSJJnknBjICA5cj0ju3FSnG1XmHgIhYnLg==",
"requires": {
"oauth": "0.9.x",
"passport-strategy": "1.x.x",
"utils-merge": "1.x.x"
}
},
"passport-oauth2": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.0.tgz",
"integrity": "sha512-emXPLqLcVEcLFR/QvQXZcwLmfK8e9CqvMgmOFJxcNT3okSFMtUbRRKpY20x5euD+01uHsjjCa07DYboEeLXYiw==",
"requires": {
"base64url": "3.x.x",
"oauth": "0.9.x",
"passport-strategy": "1.x.x",
"uid2": "0.0.x",
"utils-merge": "1.x.x"
}
},
"passport-strategy": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
"integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ="
},
"passport-twitter": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/passport-twitter/-/passport-twitter-1.0.4.tgz",
"integrity": "sha1-AaeZ4fdgvy3knyul+6MigvGJMtc=",
"requires": {
"passport-oauth1": "1.x.x",
"xtraverse": "0.1.x"
}
},
"rollup": {
"version": "2.56.3",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.3.tgz",
"integrity": "sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==",
"dev": true,
"requires": {
"fsevents": "~2.3.2"
}
},
"typescript": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
"dev": true
},
"uid2": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz",
"integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA=="
},
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"xmldom": {
"version": "0.1.31",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
"integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ=="
},
"xtraverse": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/xtraverse/-/xtraverse-0.1.0.tgz",
"integrity": "sha1-t0G60BjveNip0ug63gB7P3lZxzI=",
"requires": {
"xmldom": "0.1.x"
}
}
}
}

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "@lingdocs/lingdocs-main",
"version": "0.0.4",
"description": "type definitions for lingdocs stuff",
"main": "dist/types.js",
"module": "dist/types.js",
"types": "dist/types.d.ts",
"files": [
"dist"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
},
"repository": {
"type": "git",
"url": "git@github.com-lingdocs:lingdocs/lingdocs-main.git"
},
"peerDependencies": {
"@lingdocs/pashto-inflector": "^1.0.6"
},
"author": "lingdocs.com",
"license": "MIT",
"dependencies": {
"passport-github2": "^0.1.12",
"passport-google-oauth": "^2.0.0",
"passport-twitter": "^1.0.4"
},
"devDependencies": {
"rollup": "^2.56.3",
"typescript": "^4.4.3"
}
}

28
tsconfig.json Normal file
View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"target": "es6",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"downlevelIteration": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "ES6",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"declaration": true,
"jsx": "react-jsx",
"outDir": "dist"
},
"files": [
"types.ts",
]
}

7
types.ts Normal file
View File

@ -0,0 +1,7 @@
import * as AT from "./website/src/types/account-types";
import * as FT from "./website/src/types/functions-types";
export {
AT,
FT,
};