@eightyfourthousand/data-access 2026.3.1 → 2026.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src/index.ts → index.d.ts} +1 -2
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/lib/auth.d.ts +59 -0
- package/lib/auth.js +135 -0
- package/lib/auth.js.map +1 -0
- package/lib/bibliography.d.ts +9 -0
- package/lib/bibliography.js +31 -0
- package/lib/bibliography.js.map +1 -0
- package/lib/client-browser.d.ts +1 -0
- package/lib/client-browser.js +10 -0
- package/lib/client-browser.js.map +1 -0
- package/lib/client-server.d.ts +4 -0
- package/lib/client-server.js +19 -0
- package/lib/client-server.js.map +1 -0
- package/lib/client-ssr.d.ts +1 -0
- package/lib/client-ssr.js +24 -0
- package/lib/client-ssr.js.map +1 -0
- package/lib/client-token.d.ts +7 -0
- package/lib/client-token.js +21 -0
- package/lib/client-token.js.map +1 -0
- package/lib/feedback.d.ts +6 -0
- package/lib/feedback.js +50 -0
- package/lib/feedback.js.map +1 -0
- package/lib/folio.d.ts +11 -0
- package/lib/folio.js +32 -0
- package/lib/folio.js.map +1 -0
- package/lib/glossary/batch.d.ts +5 -0
- package/lib/glossary/batch.js +24 -0
- package/lib/glossary/batch.js.map +1 -0
- package/lib/glossary/index.d.ts +4 -0
- package/lib/glossary/index.js +5 -0
- package/lib/glossary/index.js.map +1 -0
- package/lib/glossary/instance.d.ts +10 -0
- package/lib/glossary/instance.js +29 -0
- package/lib/glossary/instance.js.map +1 -0
- package/lib/glossary/landing.d.ts +5 -0
- package/lib/glossary/landing.js +33 -0
- package/lib/glossary/landing.js.map +1 -0
- package/lib/glossary/pagination.d.ts +55 -0
- package/lib/glossary/pagination.js +255 -0
- package/lib/glossary/pagination.js.map +1 -0
- package/lib/imprint.d.ts +10 -0
- package/lib/imprint.js +24 -0
- package/lib/imprint.js.map +1 -0
- package/lib/library.d.ts +58 -0
- package/lib/library.js +119 -0
- package/lib/library.js.map +1 -0
- package/lib/local-storage.d.ts +10 -0
- package/lib/local-storage.js +25 -0
- package/lib/local-storage.js.map +1 -0
- package/lib/lookup-entity.d.ts +7 -0
- package/lib/lookup-entity.js +94 -0
- package/lib/lookup-entity.js.map +1 -0
- package/lib/panel-url.d.ts +10 -0
- package/lib/panel-url.js +23 -0
- package/lib/panel-url.js.map +1 -0
- package/lib/passage/batch.d.ts +17 -0
- package/lib/passage/batch.js +159 -0
- package/lib/passage/batch.js.map +1 -0
- package/lib/passage/index.d.ts +5 -0
- package/lib/passage/index.js +6 -0
- package/lib/passage/index.js.map +1 -0
- package/lib/passage/pagination.d.ts +43 -0
- package/lib/passage/pagination.js +170 -0
- package/lib/passage/pagination.js.map +1 -0
- package/lib/passage/read.d.ts +15 -0
- package/lib/passage/read.js +61 -0
- package/lib/passage/read.js.map +1 -0
- package/lib/passage/replace-persistence.d.ts +46 -0
- package/lib/passage/replace-persistence.js +94 -0
- package/lib/passage/replace-persistence.js.map +1 -0
- package/lib/passage/save.d.ts +16 -0
- package/lib/passage/save.js +231 -0
- package/lib/passage/save.js.map +1 -0
- package/lib/proxy.d.ts +7 -0
- package/lib/proxy.js +48 -0
- package/lib/proxy.js.map +1 -0
- package/lib/publications.d.ts +86 -0
- package/lib/publications.js +226 -0
- package/lib/publications.js.map +1 -0
- package/lib/replace.d.ts +31 -0
- package/lib/replace.js +134 -0
- package/lib/replace.js.map +1 -0
- package/lib/storage.d.ts +7 -0
- package/lib/storage.js +11 -0
- package/lib/storage.js.map +1 -0
- package/lib/types/alignment.d.ts +18 -0
- package/lib/types/alignment.js +13 -0
- package/lib/types/alignment.js.map +1 -0
- package/lib/types/annotation/abbreviation.d.ts +3 -0
- package/lib/types/annotation/abbreviation.js +20 -0
- package/lib/types/annotation/abbreviation.js.map +1 -0
- package/lib/types/annotation/annotation-type.d.ts +31 -0
- package/lib/types/annotation/annotation-type.js +81 -0
- package/lib/types/annotation/annotation-type.js.map +1 -0
- package/lib/types/annotation/annotation.d.ts +142 -0
- package/lib/types/annotation/annotation.js +23 -0
- package/lib/types/annotation/annotation.js.map +1 -0
- package/lib/types/annotation/audio.d.ts +3 -0
- package/lib/types/annotation/audio.js +24 -0
- package/lib/types/annotation/audio.js.map +1 -0
- package/lib/types/annotation/blockquote.d.ts +3 -0
- package/lib/types/annotation/blockquote.js +8 -0
- package/lib/types/annotation/blockquote.js.map +1 -0
- package/lib/types/annotation/code.d.ts +3 -0
- package/lib/types/annotation/code.js +8 -0
- package/lib/types/annotation/code.js.map +1 -0
- package/lib/types/annotation/deprecated.d.ts +3 -0
- package/lib/types/annotation/deprecated.js +8 -0
- package/lib/types/annotation/deprecated.js.map +1 -0
- package/lib/types/annotation/end-note-link.d.ts +3 -0
- package/lib/types/annotation/end-note-link.js +23 -0
- package/lib/types/annotation/end-note-link.js.map +1 -0
- package/lib/types/annotation/export.d.ts +3 -0
- package/{src/lib/types/annotation/export.ts → lib/types/annotation/export.js} +34 -36
- package/lib/types/annotation/export.js.map +1 -0
- package/lib/types/annotation/glossary-instance.d.ts +3 -0
- package/lib/types/annotation/glossary-instance.js +23 -0
- package/lib/types/annotation/glossary-instance.js.map +1 -0
- package/lib/types/annotation/has-abbreviation.d.ts +3 -0
- package/lib/types/annotation/has-abbreviation.js +20 -0
- package/lib/types/annotation/has-abbreviation.js.map +1 -0
- package/lib/types/annotation/heading.d.ts +3 -0
- package/lib/types/annotation/heading.js +23 -0
- package/lib/types/annotation/heading.js.map +1 -0
- package/lib/types/annotation/image.d.ts +3 -0
- package/lib/types/annotation/image.js +20 -0
- package/lib/types/annotation/image.js.map +1 -0
- package/lib/types/annotation/indent.d.ts +3 -0
- package/lib/types/annotation/indent.js +8 -0
- package/lib/types/annotation/indent.js.map +1 -0
- package/lib/types/annotation/index.js +5 -0
- package/lib/types/annotation/index.js.map +1 -0
- package/lib/types/annotation/inline-title.d.ts +3 -0
- package/lib/types/annotation/inline-title.js +21 -0
- package/lib/types/annotation/inline-title.js.map +1 -0
- package/lib/types/annotation/internal-link.d.ts +3 -0
- package/lib/types/annotation/internal-link.js +62 -0
- package/lib/types/annotation/internal-link.js.map +1 -0
- package/lib/types/annotation/leading-space.d.ts +3 -0
- package/lib/types/annotation/leading-space.js +8 -0
- package/lib/types/annotation/leading-space.js.map +1 -0
- package/lib/types/annotation/line-group.d.ts +3 -0
- package/lib/types/annotation/line-group.js +8 -0
- package/lib/types/annotation/line-group.js.map +1 -0
- package/lib/types/annotation/line.d.ts +3 -0
- package/lib/types/annotation/line.js +8 -0
- package/lib/types/annotation/line.js.map +1 -0
- package/lib/types/annotation/link.d.ts +3 -0
- package/lib/types/annotation/link.js +27 -0
- package/lib/types/annotation/link.js.map +1 -0
- package/lib/types/annotation/list-item.d.ts +3 -0
- package/lib/types/annotation/list-item.js +8 -0
- package/lib/types/annotation/list-item.js.map +1 -0
- package/lib/types/annotation/list.d.ts +3 -0
- package/lib/types/annotation/list.js +31 -0
- package/lib/types/annotation/list.js.map +1 -0
- package/lib/types/annotation/mantra.d.ts +3 -0
- package/lib/types/annotation/mantra.js +21 -0
- package/lib/types/annotation/mantra.js.map +1 -0
- package/lib/types/annotation/mention.d.ts +3 -0
- package/lib/types/annotation/mention.js +50 -0
- package/lib/types/annotation/mention.js.map +1 -0
- package/lib/types/annotation/paragraph.d.ts +3 -0
- package/lib/types/annotation/paragraph.js +8 -0
- package/lib/types/annotation/paragraph.js.map +1 -0
- package/lib/types/annotation/quote.d.ts +3 -0
- package/lib/types/annotation/quote.js +21 -0
- package/lib/types/annotation/quote.js.map +1 -0
- package/lib/types/annotation/quoted.d.ts +3 -0
- package/lib/types/annotation/quoted.js +21 -0
- package/lib/types/annotation/quoted.js.map +1 -0
- package/lib/types/annotation/reference.d.ts +3 -0
- package/lib/types/annotation/reference.js +8 -0
- package/lib/types/annotation/reference.js.map +1 -0
- package/lib/types/annotation/span.d.ts +3 -0
- package/lib/types/annotation/span.js +29 -0
- package/lib/types/annotation/span.js.map +1 -0
- package/lib/types/annotation/table-body-data.d.ts +3 -0
- package/lib/types/annotation/table-body-data.js +8 -0
- package/lib/types/annotation/table-body-data.js.map +1 -0
- package/lib/types/annotation/table-body-header.d.ts +3 -0
- package/lib/types/annotation/table-body-header.js +8 -0
- package/lib/types/annotation/table-body-header.js.map +1 -0
- package/lib/types/annotation/table-body-row.d.ts +3 -0
- package/lib/types/annotation/table-body-row.js +8 -0
- package/lib/types/annotation/table-body-row.js.map +1 -0
- package/lib/types/annotation/table.d.ts +3 -0
- package/lib/types/annotation/table.js +8 -0
- package/lib/types/annotation/table.js.map +1 -0
- package/lib/types/annotation/trailer.d.ts +3 -0
- package/lib/types/annotation/trailer.js +8 -0
- package/lib/types/annotation/trailer.js.map +1 -0
- package/lib/types/annotation/transform.d.ts +6 -0
- package/lib/types/annotation/transform.js +108 -0
- package/lib/types/annotation/transform.js.map +1 -0
- package/lib/types/annotation/unknown.d.ts +3 -0
- package/lib/types/annotation/unknown.js +8 -0
- package/lib/types/annotation/unknown.js.map +1 -0
- package/lib/types/bibliography.d.ts +41 -0
- package/lib/types/bibliography.js +30 -0
- package/lib/types/bibliography.js.map +1 -0
- package/{src/lib/types/client.ts → lib/types/client.d.ts} +0 -1
- package/lib/types/client.js +2 -0
- package/lib/types/client.js.map +1 -0
- package/{src/lib/types/editor-content.ts → lib/types/editor-content.d.ts} +7 -11
- package/lib/types/editor-content.js +2 -0
- package/lib/types/editor-content.js.map +1 -0
- package/lib/types/folio.d.ts +17 -0
- package/lib/types/folio.js +11 -0
- package/lib/types/folio.js.map +1 -0
- package/lib/types/glossary-page.d.ts +48 -0
- package/lib/types/glossary-page.js +21 -0
- package/lib/types/glossary-page.js.map +1 -0
- package/lib/types/glossary.d.ts +76 -0
- package/lib/types/glossary.js +32 -0
- package/lib/types/glossary.js.map +1 -0
- package/lib/types/imprint.d.ts +78 -0
- package/lib/types/imprint.js +71 -0
- package/lib/types/imprint.js.map +1 -0
- package/{src/lib/types/index.ts → lib/types/index.d.ts} +0 -3
- package/lib/types/index.js +20 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/language.d.ts +9 -0
- package/lib/types/language.js +41 -0
- package/lib/types/language.js.map +1 -0
- package/lib/types/layout.d.ts +5 -0
- package/lib/types/layout.js +23 -0
- package/lib/types/layout.js.map +1 -0
- package/lib/types/library.d.ts +19 -0
- package/lib/types/library.js +8 -0
- package/lib/types/library.js.map +1 -0
- package/lib/types/passage.d.ts +73 -0
- package/lib/types/passage.js +120 -0
- package/lib/types/passage.js.map +1 -0
- package/lib/types/semver.js +2 -0
- package/lib/types/semver.js.map +1 -0
- package/lib/types/title.d.ts +21 -0
- package/lib/types/title.js +22 -0
- package/lib/types/title.js.map +1 -0
- package/lib/types/toh.js +2 -0
- package/lib/types/toh.js.map +1 -0
- package/{src/lib/types/translation.ts → lib/types/translation.d.ts} +5 -7
- package/lib/types/translation.js +2 -0
- package/lib/types/translation.js.map +1 -0
- package/{src/lib/types/user.ts → lib/types/user.d.ts} +2 -11
- package/lib/types/user.js +9 -0
- package/lib/types/user.js.map +1 -0
- package/lib/types/work.d.ts +37 -0
- package/lib/types/work.js +15 -0
- package/lib/types/work.js.map +1 -0
- package/lib/use-bookmark.d.ts +10 -0
- package/lib/use-bookmark.js +31 -0
- package/lib/use-bookmark.js.map +1 -0
- package/package.json +25 -3
- package/ssr.js +6 -0
- package/ssr.js.map +1 -0
- package/.babelrc +0 -12
- package/.eslintrc.json +0 -18
- package/README.md +0 -9
- package/jest.config.ts +0 -10
- package/project.json +0 -21
- package/src/lib/auth.ts +0 -203
- package/src/lib/bibliography.ts +0 -57
- package/src/lib/canon.ts +0 -111
- package/src/lib/client-browser.ts +0 -12
- package/src/lib/client-server.ts +0 -30
- package/src/lib/client-ssr.ts +0 -24
- package/src/lib/client-token.ts +0 -24
- package/src/lib/feedback.ts +0 -71
- package/src/lib/folio.ts +0 -43
- package/src/lib/glossary.ts +0 -147
- package/src/lib/imprint.ts +0 -42
- package/src/lib/library.ts +0 -209
- package/src/lib/local-storage.ts +0 -33
- package/src/lib/lookup-entity.ts +0 -122
- package/src/lib/panel-url.ts +0 -43
- package/src/lib/passage.ts +0 -122
- package/src/lib/projects.ts +0 -107
- package/src/lib/proxy.ts +0 -68
- package/src/lib/publications.ts +0 -213
- package/src/lib/storage.ts +0 -23
- package/src/lib/types/alignment.ts +0 -32
- package/src/lib/types/annotation/abbreviation.ts +0 -30
- package/src/lib/types/annotation/annotation-type.ts +0 -219
- package/src/lib/types/annotation/annotation.ts +0 -244
- package/src/lib/types/annotation/audio.ts +0 -33
- package/src/lib/types/annotation/blockquote.ts +0 -18
- package/src/lib/types/annotation/code.ts +0 -16
- package/src/lib/types/annotation/deprecated.ts +0 -18
- package/src/lib/types/annotation/end-note-link.ts +0 -35
- package/src/lib/types/annotation/glossary-instance.ts +0 -34
- package/src/lib/types/annotation/has-abbreviation.ts +0 -30
- package/src/lib/types/annotation/heading.ts +0 -37
- package/src/lib/types/annotation/image.ts +0 -29
- package/src/lib/types/annotation/indent.ts +0 -16
- package/src/lib/types/annotation/inline-title.ts +0 -34
- package/src/lib/types/annotation/internal-link.ts +0 -86
- package/src/lib/types/annotation/leading-space.ts +0 -18
- package/src/lib/types/annotation/line-group.ts +0 -18
- package/src/lib/types/annotation/line.ts +0 -16
- package/src/lib/types/annotation/link.ts +0 -38
- package/src/lib/types/annotation/list-item.ts +0 -16
- package/src/lib/types/annotation/list.ts +0 -43
- package/src/lib/types/annotation/mantra.ts +0 -31
- package/src/lib/types/annotation/mention.ts +0 -64
- package/src/lib/types/annotation/paragraph.ts +0 -18
- package/src/lib/types/annotation/quote.ts +0 -30
- package/src/lib/types/annotation/quoted.ts +0 -30
- package/src/lib/types/annotation/reference.ts +0 -18
- package/src/lib/types/annotation/span.ts +0 -39
- package/src/lib/types/annotation/table-body-data.ts +0 -18
- package/src/lib/types/annotation/table-body-header.ts +0 -18
- package/src/lib/types/annotation/table-body-row.ts +0 -18
- package/src/lib/types/annotation/table.ts +0 -16
- package/src/lib/types/annotation/trailer.ts +0 -16
- package/src/lib/types/annotation/transform.ts +0 -140
- package/src/lib/types/annotation/unknown.ts +0 -16
- package/src/lib/types/bibliography.ts +0 -86
- package/src/lib/types/canon.ts +0 -148
- package/src/lib/types/contributor.ts +0 -84
- package/src/lib/types/folio.ts +0 -28
- package/src/lib/types/glossary-page.ts +0 -204
- package/src/lib/types/glossary.ts +0 -114
- package/src/lib/types/imprint.ts +0 -159
- package/src/lib/types/language.ts +0 -64
- package/src/lib/types/layout.ts +0 -37
- package/src/lib/types/library.ts +0 -29
- package/src/lib/types/passage.ts +0 -220
- package/src/lib/types/project.ts +0 -200
- package/src/lib/types/title.ts +0 -47
- package/src/lib/types/work.ts +0 -38
- package/src/lib/use-bookmark.ts +0 -45
- package/tsconfig.json +0 -20
- package/tsconfig.lib.json +0 -26
- package/tsconfig.spec.json +0 -22
- /package/{src/lib/types/annotation/index.ts → lib/types/annotation/index.d.ts} +0 -0
- /package/{src/lib/types/semver.ts → lib/types/semver.d.ts} +0 -0
- /package/{src/lib/types/toh.ts → lib/types/toh.d.ts} +0 -0
- /package/{src/ssr.ts → ssr.d.ts} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './lib/auth';
|
|
2
2
|
export * from './lib/bibliography';
|
|
3
|
-
export * from './lib/canon';
|
|
4
3
|
export * from './lib/client-browser';
|
|
5
4
|
export * from './lib/client-server';
|
|
6
5
|
export * from './lib/client-token';
|
|
@@ -10,8 +9,8 @@ export * from './lib/imprint';
|
|
|
10
9
|
export * from './lib/panel-url';
|
|
11
10
|
export * from './lib/library';
|
|
12
11
|
export * from './lib/passage';
|
|
13
|
-
export * from './lib/projects';
|
|
14
12
|
export * from './lib/publications';
|
|
13
|
+
export * from './lib/replace';
|
|
15
14
|
export * from './lib/storage';
|
|
16
15
|
export * from './lib/types';
|
|
17
16
|
export * from './lib/local-storage';
|
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './lib/auth';
|
|
2
|
+
export * from './lib/bibliography';
|
|
3
|
+
export * from './lib/client-browser';
|
|
4
|
+
export * from './lib/client-server';
|
|
5
|
+
export * from './lib/client-token';
|
|
6
|
+
export * from './lib/folio';
|
|
7
|
+
export * from './lib/glossary';
|
|
8
|
+
export * from './lib/imprint';
|
|
9
|
+
export * from './lib/panel-url';
|
|
10
|
+
export * from './lib/library';
|
|
11
|
+
export * from './lib/passage';
|
|
12
|
+
export * from './lib/publications';
|
|
13
|
+
export * from './lib/replace';
|
|
14
|
+
export * from './lib/storage';
|
|
15
|
+
export * from './lib/types';
|
|
16
|
+
export * from './lib/local-storage';
|
|
17
|
+
export * from './lib/use-bookmark';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/data-access/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
package/lib/auth.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DataClient, UserClaims, UserPermission, UserRole } from './types';
|
|
2
|
+
export declare const getSession: ({ client }: {
|
|
3
|
+
client: DataClient;
|
|
4
|
+
}) => Promise<{
|
|
5
|
+
provider_token?: string | null;
|
|
6
|
+
provider_refresh_token?: string | null;
|
|
7
|
+
access_token: string;
|
|
8
|
+
refresh_token: string;
|
|
9
|
+
expires_in: number;
|
|
10
|
+
expires_at?: number;
|
|
11
|
+
token_type: "bearer";
|
|
12
|
+
user: import("@supabase/auth-js").User;
|
|
13
|
+
claims: UserClaims;
|
|
14
|
+
} | null>;
|
|
15
|
+
export declare const getUser: ({ client }: {
|
|
16
|
+
client: DataClient;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
id: string;
|
|
19
|
+
email: string;
|
|
20
|
+
username: any;
|
|
21
|
+
name: any;
|
|
22
|
+
avatar: any;
|
|
23
|
+
role: UserRole;
|
|
24
|
+
subscriptions: any[];
|
|
25
|
+
} | null>;
|
|
26
|
+
export declare const hasPermission: ({ client, permission, }: {
|
|
27
|
+
client: DataClient;
|
|
28
|
+
permission: UserPermission;
|
|
29
|
+
}) => Promise<boolean>;
|
|
30
|
+
export declare const loginWithGoogle: ({ client, redirectTo, }: {
|
|
31
|
+
client: DataClient;
|
|
32
|
+
redirectTo: string | undefined;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
export declare const loginWithApple: ({ client, redirectTo, }: {
|
|
35
|
+
client: DataClient;
|
|
36
|
+
redirectTo: string | undefined;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
export declare const loginWithEmail: ({ client, email, password, }: {
|
|
39
|
+
client: DataClient;
|
|
40
|
+
email: string;
|
|
41
|
+
password: string;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
export declare const logout: ({ client }: {
|
|
44
|
+
client: DataClient;
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
export declare const resetPassword: ({ client, email, redirectTo, }: {
|
|
47
|
+
client: DataClient;
|
|
48
|
+
email: string;
|
|
49
|
+
redirectTo?: string;
|
|
50
|
+
}) => Promise<void>;
|
|
51
|
+
export declare const signUpWithEmail: ({ client, email, password, redirectTo, }: {
|
|
52
|
+
client: DataClient;
|
|
53
|
+
email: string;
|
|
54
|
+
password: string;
|
|
55
|
+
redirectTo?: string;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
export declare const deleteAccount: ({ client }: {
|
|
58
|
+
client: DataClient;
|
|
59
|
+
}) => Promise<void>;
|
package/lib/auth.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { jwtDecode } from 'jwt-decode';
|
|
3
|
+
export const getSession = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client }) {
|
|
4
|
+
const { data, error } = yield client.auth.getSession();
|
|
5
|
+
if (error || !(data === null || data === void 0 ? void 0 : data.session)) {
|
|
6
|
+
console.info(`Failed to get session data: ${error}`);
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const { access_token } = data.session;
|
|
10
|
+
if (!access_token) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const decoded = jwtDecode(access_token);
|
|
15
|
+
const { user_role: role = 'reader' } = decoded;
|
|
16
|
+
const claims = {
|
|
17
|
+
role,
|
|
18
|
+
};
|
|
19
|
+
return Object.assign({ claims }, data.session);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error('Failed to decode JWT:', error);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export const getUser = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client }) {
|
|
27
|
+
const session = yield getSession({ client });
|
|
28
|
+
if (!session) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const { claims, user } = session;
|
|
32
|
+
const { role } = claims;
|
|
33
|
+
const { id, email, user_metadata: metadata } = user;
|
|
34
|
+
const { name, picture } = metadata;
|
|
35
|
+
if (!id || !email) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const { error, data } = yield client
|
|
39
|
+
.from('user_profiles')
|
|
40
|
+
.select('username, fullName:full_name, avatar:avatar_url, subscriptions')
|
|
41
|
+
.eq('id', id)
|
|
42
|
+
.single();
|
|
43
|
+
if (error) {
|
|
44
|
+
console.warn(`Failed to fetch user profile: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
const { username, fullName, avatar, subscriptions } = data || {};
|
|
47
|
+
const subsArray = Array.isArray(subscriptions) ? subscriptions : [];
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
email,
|
|
51
|
+
username: username || email,
|
|
52
|
+
name: fullName || name,
|
|
53
|
+
avatar: avatar || picture,
|
|
54
|
+
role,
|
|
55
|
+
subscriptions: subsArray,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
export const hasPermission = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, permission, }) {
|
|
59
|
+
const { data, error } = yield client.rpc('authorize', {
|
|
60
|
+
requested_permission: permission,
|
|
61
|
+
});
|
|
62
|
+
if (error) {
|
|
63
|
+
console.error(`Failed to check permission: ${error.message}`);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return data;
|
|
67
|
+
});
|
|
68
|
+
export const loginWithGoogle = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, redirectTo = undefined, }) {
|
|
69
|
+
yield client.auth.signInWithOAuth({
|
|
70
|
+
provider: 'google',
|
|
71
|
+
options: {
|
|
72
|
+
redirectTo,
|
|
73
|
+
queryParams: {
|
|
74
|
+
access_type: 'offline',
|
|
75
|
+
prompt: 'consent',
|
|
76
|
+
hd: '84000.co',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
export const loginWithApple = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, redirectTo = undefined, }) {
|
|
82
|
+
yield client.auth.signInWithOAuth({
|
|
83
|
+
provider: 'apple',
|
|
84
|
+
options: {
|
|
85
|
+
redirectTo,
|
|
86
|
+
queryParams: {
|
|
87
|
+
scope: 'email name',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
export const loginWithEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, email, password, }) {
|
|
93
|
+
const { error } = yield client.auth.signInWithPassword({
|
|
94
|
+
email,
|
|
95
|
+
password,
|
|
96
|
+
});
|
|
97
|
+
if (error) {
|
|
98
|
+
console.error(`Failed to login with email: ${error.message}`);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
export const logout = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client }) {
|
|
103
|
+
yield client.auth.signOut();
|
|
104
|
+
});
|
|
105
|
+
export const resetPassword = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, email, redirectTo = undefined, }) {
|
|
106
|
+
const { error } = yield client.auth.resetPasswordForEmail(email, {
|
|
107
|
+
redirectTo,
|
|
108
|
+
});
|
|
109
|
+
if (error) {
|
|
110
|
+
console.error(`Failed to reset password: ${error.message}`);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
export const signUpWithEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, email, password, redirectTo = undefined, }) {
|
|
115
|
+
const { error } = yield client.auth.signUp({
|
|
116
|
+
email,
|
|
117
|
+
password,
|
|
118
|
+
options: {
|
|
119
|
+
emailRedirectTo: redirectTo,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
if (error) {
|
|
123
|
+
console.error(`Failed to sign up with email: ${error.message}`);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
export const deleteAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client }) {
|
|
128
|
+
const { error } = yield client.rpc('scholar_account_delete');
|
|
129
|
+
if (error) {
|
|
130
|
+
console.error(`Failed to delete account: ${error.message}`);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
yield logout({ client });
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=auth.js.map
|
package/lib/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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K,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,MAAM,KAAK,CAAC;IACd,CAAC;IAED,MAAM,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3B,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataClient } from './types';
|
|
2
|
+
export declare const getBibliographyEntries: ({ client, uuid, }: {
|
|
3
|
+
client: DataClient;
|
|
4
|
+
uuid: string;
|
|
5
|
+
}) => Promise<import("./types").BibliographyEntries>;
|
|
6
|
+
export declare const getBibliographyEntry: ({ client, uuid, }: {
|
|
7
|
+
client: DataClient;
|
|
8
|
+
uuid: string;
|
|
9
|
+
}) => Promise<import("./types").BibliographyEntryItem | null>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { bibliographyEntriesFromDTO, bibliographyEntryItemFromDTO, } from './types';
|
|
3
|
+
export const getBibliographyEntries = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, uuid, }) {
|
|
4
|
+
const { data, error } = yield client.rpc('show_bibliographies', {
|
|
5
|
+
v_work_uuid: uuid,
|
|
6
|
+
});
|
|
7
|
+
if (error) {
|
|
8
|
+
console.error(`Error fetching glossary instances for work: ${uuid} `, error);
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const dto = data;
|
|
12
|
+
return bibliographyEntriesFromDTO(dto);
|
|
13
|
+
});
|
|
14
|
+
export const getBibliographyEntry = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, uuid, }) {
|
|
15
|
+
const { data, error } = yield client
|
|
16
|
+
.from('bibliographies')
|
|
17
|
+
.select(`
|
|
18
|
+
uuid::uuid,
|
|
19
|
+
work_uuid::uuid,
|
|
20
|
+
bibl_html::text
|
|
21
|
+
`)
|
|
22
|
+
.eq('uuid', uuid)
|
|
23
|
+
.single();
|
|
24
|
+
if (error) {
|
|
25
|
+
console.error(`Error fetching bibliography entry: ${uuid} `, error);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const dto = data;
|
|
29
|
+
return bibliographyEntryItemFromDTO(dto);
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=bibliography.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bibliography.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/bibliography.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,0BAA0B,EAE1B,4BAA4B,GAE7B,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAMnC,EAAE,4CANwC,EAC3C,MAAM,EACN,IAAI,GAIL;IACC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE;QAC9D,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CACX,+CAA+C,IAAI,GAAG,EACtD,KAAK,CACN,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAG,IAA8B,CAAC;IAC3C,OAAO,0BAA0B,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAMjC,EAAE,4CANsC,EACzC,MAAM,EACN,IAAI,GAIL;IACC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM;SACjC,IAAI,CAAC,gBAAgB,CAAC;SACtB,MAAM,CACL;;;;CAIL,CACI;SACA,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;SAChB,MAAM,EAAE,CAAC;IACZ,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,sCAAsC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,IAAgC,CAAC;IAE7C,OAAO,4BAA4B,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createBrowserClient: () => import("@supabase/supabase-js").SupabaseClient<any, "public", any, any, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createBrowserClient as createSupabaseClient } from '@supabase/ssr';
|
|
2
|
+
export const createBrowserClient = () => {
|
|
3
|
+
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
4
|
+
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
5
|
+
if (!supabaseUrl || !supabaseAnonKey) {
|
|
6
|
+
throw new Error('Missing Supabase credentials');
|
|
7
|
+
}
|
|
8
|
+
return createSupabaseClient(supabaseUrl, supabaseAnonKey);
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=client-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-browser.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/client-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACzD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;IAElE,IAAI,CAAC,WAAW,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,oBAAoB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createServerClient as createSupabaseClient, } from '@supabase/ssr';
|
|
2
|
+
export const createServerClient = ({ cookies, }) => {
|
|
3
|
+
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
4
|
+
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
5
|
+
if (!supabaseUrl || !supabaseAnonKey) {
|
|
6
|
+
throw new Error('Missing Supabase credentials');
|
|
7
|
+
}
|
|
8
|
+
const client = createSupabaseClient(supabaseUrl, supabaseAnonKey, {
|
|
9
|
+
cookies,
|
|
10
|
+
});
|
|
11
|
+
// NOTE: we suppress the warning about getSession being called. But is is
|
|
12
|
+
// import not to rely on this method for authorization. Rather, it is
|
|
13
|
+
// convenient for early exists in server components.
|
|
14
|
+
//
|
|
15
|
+
// @ts-expect-error - suppressGetSessionWarning is protected
|
|
16
|
+
client.auth.suppressGetSessionWarning = true;
|
|
17
|
+
return client;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=client-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-server.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/client-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,IAAI,oBAAoB,GAC3C,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,OAAO,GAGR,EAAE,EAAE;IACH,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACzD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;IAElE,IAAI,CAAC,WAAW,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,EAAE,eAAe,EAAE;QAChE,OAAO;KACR,CAAC,CAAC;IAEH,yEAAyE;IACzE,qEAAqE;IACrE,oDAAoD;IACpD,EAAE;IACF,4DAA4D;IAC5D,MAAM,CAAC,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAE7C,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createServerClient: () => Promise<import("@supabase/supabase-js").SupabaseClient<any, "public", any, any, any>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { createServerClient as createSupabaseClient } from './client-server';
|
|
3
|
+
import { cookies } from 'next/headers';
|
|
4
|
+
export const createServerClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5
|
+
const cookieStore = yield cookies();
|
|
6
|
+
return createSupabaseClient({
|
|
7
|
+
cookies: {
|
|
8
|
+
getAll: () => {
|
|
9
|
+
return cookieStore.getAll();
|
|
10
|
+
},
|
|
11
|
+
setAll: (cookiesToSet) => {
|
|
12
|
+
try {
|
|
13
|
+
cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
|
|
14
|
+
}
|
|
15
|
+
catch (_a) {
|
|
16
|
+
// The `setAll` method was called from a Server Component.
|
|
17
|
+
// This can be ignored if you have middleware refreshing
|
|
18
|
+
// user sessions.
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=client-ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-ssr.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/client-ssr.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,IAAI,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAS,EAAE;IAC3C,MAAM,WAAW,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,OAAO,oBAAoB,CAAC;QAC1B,OAAO,EAAE;YACP,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,WAAW,CAAC,MAAM,EAAE,CAAC;YAC9B,CAAC;YACD,MAAM,EAAE,CAAC,YAAY,EAAE,EAAE;gBACvB,IAAI,CAAC;oBACH,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAChD,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CACtC,CAAC;gBACJ,CAAC;gBAAC,WAAM,CAAC;oBACP,0DAA0D;oBAC1D,wDAAwD;oBACxD,iBAAiB;gBACnB,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DataClient } from './types/client';
|
|
2
|
+
/**
|
|
3
|
+
* Create a Supabase client using an access token for authentication.
|
|
4
|
+
* Use this for API routes that receive tokens via Authorization header
|
|
5
|
+
* instead of cookies (e.g., cross-domain requests).
|
|
6
|
+
*/
|
|
7
|
+
export declare const createTokenClient: (accessToken: string) => DataClient;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createClient } from '@supabase/supabase-js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a Supabase client using an access token for authentication.
|
|
4
|
+
* Use this for API routes that receive tokens via Authorization header
|
|
5
|
+
* instead of cookies (e.g., cross-domain requests).
|
|
6
|
+
*/
|
|
7
|
+
export const createTokenClient = (accessToken) => {
|
|
8
|
+
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
9
|
+
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
10
|
+
if (!supabaseUrl || !supabaseAnonKey) {
|
|
11
|
+
throw new Error('Missing Supabase credentials');
|
|
12
|
+
}
|
|
13
|
+
return createClient(supabaseUrl, supabaseAnonKey, {
|
|
14
|
+
global: {
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${accessToken}`,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=client-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-token.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/client-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAc,EAAE;IACnE,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IACzD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;IAElE,IAAI,CAAC,WAAW,IAAI,CAAC,eAAe,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,YAAY,CAAC,WAAW,EAAE,eAAe,EAAE;QAChD,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;aACvC;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/lib/feedback.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { parseToh } from '@eightyfourthousand/lib-utils';
|
|
3
|
+
import { NextResponse } from 'next/server';
|
|
4
|
+
import { Resend } from 'resend';
|
|
5
|
+
function sendRevisionEmail(_a) {
|
|
6
|
+
return __awaiter(this, arguments, void 0, function* ({ toh, type, label, body, }) {
|
|
7
|
+
const apiKey = process.env['RESEND_API_KEY'];
|
|
8
|
+
const from = process.env['FEEDBACK_SENDER'];
|
|
9
|
+
const to = process.env['FEEDBACK_RECIPIENT'];
|
|
10
|
+
if (!apiKey || !from || !to) {
|
|
11
|
+
throw new Error('Missing email configuration environment variables');
|
|
12
|
+
}
|
|
13
|
+
const resend = new Resend(apiKey);
|
|
14
|
+
const trimmedLabel = label.split('\n').join(', ').trim();
|
|
15
|
+
const subject = `[Revision Suggestion] ${parseToh(toh)} - ${type} ${trimmedLabel}`;
|
|
16
|
+
const { error } = yield resend.emails.send({
|
|
17
|
+
from,
|
|
18
|
+
to,
|
|
19
|
+
subject,
|
|
20
|
+
text: body,
|
|
21
|
+
});
|
|
22
|
+
if (error) {
|
|
23
|
+
throw new Error(error.message);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function handleFeedbackPost(request) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
const { toh, type, label, body } = yield request.json();
|
|
31
|
+
if (typeof toh !== 'string' ||
|
|
32
|
+
!toh.trim() ||
|
|
33
|
+
typeof type !== 'string' ||
|
|
34
|
+
!type.trim() ||
|
|
35
|
+
typeof label !== 'string' ||
|
|
36
|
+
!label.trim() ||
|
|
37
|
+
typeof body !== 'string' ||
|
|
38
|
+
!body.trim()) {
|
|
39
|
+
return NextResponse.json({ error: 'All fields (toh, type, label, body) are required.' }, { status: 400 });
|
|
40
|
+
}
|
|
41
|
+
yield sendRevisionEmail({ toh, type, label, body });
|
|
42
|
+
return NextResponse.json({ success: true });
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
console.error('Failed to send revision email:', error);
|
|
46
|
+
return NextResponse.json({ error: 'Failed to send feedback.' }, { status: 500 });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/feedback.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC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,IACE,OAAO,GAAG,KAAK,QAAQ;gBACvB,CAAC,GAAG,CAAC,IAAI,EAAE;gBACX,OAAO,IAAI,KAAK,QAAQ;gBACxB,CAAC,IAAI,CAAC,IAAI,EAAE;gBACZ,OAAO,KAAK,KAAK,QAAQ;gBACzB,CAAC,KAAK,CAAC,IAAI,EAAE;gBACb,OAAO,IAAI,KAAK,QAAQ;gBACxB,CAAC,IAAI,CAAC,IAAI,EAAE,EACZ,CAAC;gBACD,OAAO,YAAY,CAAC,IAAI,CACtB,EAAE,KAAK,EAAE,mDAAmD,EAAE,EAC9D,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC;YACJ,CAAC;YAED,MAAM,iBAAiB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAEpD,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,YAAY,CAAC,IAAI,CACtB,EAAE,KAAK,EAAE,0BAA0B,EAAE,EACrC,EAAE,MAAM,EAAE,GAAG,EAAE,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;CAAA"}
|
package/lib/folio.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataClient, TohokuCatalogEntry } from './types';
|
|
2
|
+
type GetWorkFoliosArgs = {
|
|
3
|
+
client: DataClient;
|
|
4
|
+
uuid: string;
|
|
5
|
+
toh: TohokuCatalogEntry;
|
|
6
|
+
page?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const getWorkFolios: ({ client, uuid, toh, page, size, }: GetWorkFoliosArgs) => Promise<import("./types").Folio[]>;
|
|
10
|
+
export declare const getFolios: ({ uuid, toh, page, size, }: Omit<GetWorkFoliosArgs, "client">) => Promise<import("./types").Folio[]>;
|
|
11
|
+
export {};
|
package/lib/folio.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use server';
|
|
2
|
+
import { __awaiter } from "tslib";
|
|
3
|
+
import { createServerClient } from './client-ssr';
|
|
4
|
+
import { folioFromDTO } from './types/folio';
|
|
5
|
+
export const getWorkFolios = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, uuid, toh, page = 0, size = 10, }) {
|
|
6
|
+
const start = page * size;
|
|
7
|
+
const end = start + size - 1;
|
|
8
|
+
const { data, error } = yield client
|
|
9
|
+
.from('tibetan_works_folios')
|
|
10
|
+
.select(`
|
|
11
|
+
folio_uuid,
|
|
12
|
+
content::text,
|
|
13
|
+
volume_number::int4,
|
|
14
|
+
folio_number::int4,
|
|
15
|
+
side::text`)
|
|
16
|
+
.eq('work_uuid', uuid)
|
|
17
|
+
.eq('toh', toh)
|
|
18
|
+
.order('volume_number', { ascending: true })
|
|
19
|
+
.order('folio_number', { ascending: true })
|
|
20
|
+
.order('side', { ascending: true })
|
|
21
|
+
.range(start, end);
|
|
22
|
+
if (error) {
|
|
23
|
+
console.error('Error fetching folios:', error);
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return data.map((dto) => folioFromDTO(dto));
|
|
27
|
+
});
|
|
28
|
+
export const getFolios = (_a) => __awaiter(void 0, [_a], void 0, function* ({ uuid, toh, page = 0, size = 10, }) {
|
|
29
|
+
const client = yield createServerClient();
|
|
30
|
+
return getWorkFolios({ client, uuid, toh, page, size });
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=folio.js.map
|
package/lib/folio.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folio.js","sourceRoot":"","sources":["../../../../libs/data-access/src/lib/folio.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAY,YA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AAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
export const getGlossaryDisplayNamesByUuids = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, glossaryUuids, }) {
|
|
3
|
+
var _b;
|
|
4
|
+
const namesByUuid = new Map();
|
|
5
|
+
if (glossaryUuids.length === 0)
|
|
6
|
+
return namesByUuid;
|
|
7
|
+
const { data, error } = yield client
|
|
8
|
+
.from('glossaries')
|
|
9
|
+
.select('uuid, names:names!name_uuid(content)')
|
|
10
|
+
.in('uuid', glossaryUuids);
|
|
11
|
+
if (error) {
|
|
12
|
+
console.error('Error batch loading glossary names:', error);
|
|
13
|
+
return namesByUuid;
|
|
14
|
+
}
|
|
15
|
+
for (const glossary of data !== null && data !== void 0 ? data : []) {
|
|
16
|
+
const names = glossary.names;
|
|
17
|
+
const content = Array.isArray(names) ? (_b = names[0]) === null || _b === void 0 ? void 0 : _b.content : names === null || names === void 0 ? void 0 : names.content;
|
|
18
|
+
if (content) {
|
|
19
|
+
namesByUuid.set(glossary.uuid, content);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return namesByUuid;
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","sourceRoot":"","sources":["../../../../../libs/data-access/src/lib/glossary/batch.ts"],"names":[],"mappings":";AAEA,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAMb,EAAE,4CANkB,EACnD,MAAM,EACN,aAAa,GAId;;IACC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAEnD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM;SACjC,IAAI,CAAC,YAAY,CAAC;SAClB,MAAM,CAAC,sCAAsC,CAAC;SAC9C,EAAE,CAAC,MAAM,EAAE,aAAyB,CAAC,CAAC;IAEzC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAGf,CAAC;QACT,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,OAAO,CAAC,CAAC,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC;QAC1E,IAAI,OAAO,EAAE,CAAC;YACZ,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/data-access/src/lib/glossary/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DataClient } from '../types';
|
|
2
|
+
export declare const getGlossaryInstances: ({ client, uuid, withAttestations, }: {
|
|
3
|
+
client: DataClient;
|
|
4
|
+
uuid: string;
|
|
5
|
+
withAttestations?: boolean;
|
|
6
|
+
}) => Promise<import("../types").GlossaryTermInstance[]>;
|
|
7
|
+
export declare const getGlossaryInstance: ({ client, uuid, }: {
|
|
8
|
+
client: DataClient;
|
|
9
|
+
uuid: string;
|
|
10
|
+
}) => Promise<import("../types").GlossaryTermInstance | undefined>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { glossaryTermInstanceFromDTO, } from '../types';
|
|
3
|
+
export const getGlossaryInstances = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, uuid, withAttestations = false, }) {
|
|
4
|
+
const { data, error } = yield client.rpc('show_glossary_entries', {
|
|
5
|
+
v_work_uuid: uuid,
|
|
6
|
+
v_with_attestation: withAttestations,
|
|
7
|
+
});
|
|
8
|
+
if (error) {
|
|
9
|
+
console.error(`Error fetching glossary instances for work: ${uuid} `, error);
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const dto = data;
|
|
13
|
+
return dto.glossary_entries.map(glossaryTermInstanceFromDTO).sort((a, b) => {
|
|
14
|
+
const nameA = a.names.english || '';
|
|
15
|
+
const nameB = b.names.english || '';
|
|
16
|
+
return nameA.localeCompare(nameB);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
export const getGlossaryInstance = (_a) => __awaiter(void 0, [_a], void 0, function* ({ client, uuid, }) {
|
|
20
|
+
const { data, error } = yield client.rpc('show_glossary_entry', {
|
|
21
|
+
v_glossary_uuid: uuid,
|
|
22
|
+
});
|
|
23
|
+
if (error) {
|
|
24
|
+
console.error(`Error fetching glossary instance: ${uuid} `, error);
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return glossaryTermInstanceFromDTO(data);
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../../../libs/data-access/src/lib/glossary/instance.ts"],"names":[],"mappings":";AAAA,OAAO,EAIL,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAElB,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAQjC,EAAE,4CARsC,E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