@openrails/contentkit-ui 0.79.0 → 0.81.0
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/README.md +82 -54
- package/dist/client/beacons.d.ts +53 -0
- package/dist/client/beacons.js +72 -0
- package/dist/client/beacons.js.map +1 -0
- package/dist/client/catalog.d.ts +2 -2
- package/dist/client/catalog.js +1 -1
- package/dist/client/catalog.js.map +1 -1
- package/dist/client/client.d.ts +24 -11
- package/dist/client/client.js +37 -29
- package/dist/client/client.js.map +1 -1
- package/dist/client/content/comments.d.ts +12 -8
- package/dist/client/content/comments.js +33 -20
- package/dist/client/content/comments.js.map +1 -1
- package/dist/client/content/favorites.d.ts +24 -9
- package/dist/client/content/favorites.js +21 -22
- package/dist/client/content/favorites.js.map +1 -1
- package/dist/client/content/moderation.d.ts +1 -1
- package/dist/client/content/moderation.js.map +1 -1
- package/dist/client/content/reactions.d.ts +11 -6
- package/dist/client/content/reactions.js +23 -18
- package/dist/client/content/reactions.js.map +1 -1
- package/dist/client/content/types.d.ts +40 -21
- package/dist/client/content/types.js +5 -2
- package/dist/client/content/types.js.map +1 -1
- package/dist/client/contents.d.ts +55 -0
- package/dist/client/contents.js +144 -0
- package/dist/client/contents.js.map +1 -0
- package/dist/client/discovery.d.ts +126 -0
- package/dist/client/discovery.js +125 -0
- package/dist/client/discovery.js.map +1 -0
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/error-codes.js +12 -0
- package/dist/client/generated/error-codes.js.map +1 -1
- package/dist/client/generated/routes.d.ts +1244 -370
- package/dist/client/generated/routes.js +1870 -554
- package/dist/client/generated/routes.js.map +1 -1
- package/dist/client/generated/wire.d.ts +960 -134
- package/dist/client/generated/wire.js.map +1 -1
- package/dist/client/group-fields.d.ts +25 -0
- package/dist/client/group-fields.js +63 -0
- package/dist/client/group-fields.js.map +1 -0
- package/dist/client/groups.d.ts +58 -0
- package/dist/client/groups.js +119 -0
- package/dist/client/groups.js.map +1 -0
- package/dist/client/http.d.ts +24 -12
- package/dist/client/http.js +20 -24
- package/dist/client/http.js.map +1 -1
- package/dist/client/index.d.ts +11 -6
- package/dist/client/media/api.d.ts +1 -1
- package/dist/client/media/api.js +4 -2
- package/dist/client/media/api.js.map +1 -1
- package/dist/client/media/client.d.ts +8 -9
- package/dist/client/media/client.js +58 -71
- package/dist/client/media/client.js.map +1 -1
- package/dist/client/media/ref.d.ts +30 -0
- package/dist/client/media/ref.js +10 -3
- package/dist/client/media/ref.js.map +1 -1
- package/dist/client/offers.d.ts +41 -0
- package/dist/client/offers.js +66 -0
- package/dist/client/offers.js.map +1 -0
- package/dist/client/route.d.ts +2 -0
- package/dist/client/route.js +2 -1
- package/dist/client/route.js.map +1 -1
- package/dist/client/versions.d.ts +20 -0
- package/dist/client/versions.js +53 -0
- package/dist/client/versions.js.map +1 -0
- package/dist/client.js +35 -30
- package/dist/components/admin/content-manager.d.ts +80 -0
- package/dist/components/admin/content-manager.js +591 -0
- package/dist/components/admin/content-manager.js.map +1 -0
- package/dist/components/admin/group-manager.d.ts +24 -0
- package/dist/components/admin/group-manager.js +244 -0
- package/dist/components/admin/group-manager.js.map +1 -0
- package/dist/components/admin/media-item-panel.js +1 -1
- package/dist/components/admin/media-item-panel.js.map +1 -1
- package/dist/components/content/card.d.ts +44 -0
- package/dist/components/content/card.js +285 -0
- package/dist/components/content/card.js.map +1 -0
- package/dist/components/content/editors.d.ts +40 -0
- package/dist/components/content/editors.js +764 -0
- package/dist/components/content/editors.js.map +1 -0
- package/dist/components/content/filters.d.ts +28 -0
- package/dist/components/content/filters.js +134 -0
- package/dist/components/content/filters.js.map +1 -0
- package/dist/components/content/grid.d.ts +62 -0
- package/dist/components/content/grid.js +233 -0
- package/dist/components/content/grid.js.map +1 -0
- package/dist/components/content/index.d.ts +8 -0
- package/dist/components/content/listing.d.ts +20 -0
- package/dist/components/content/listing.js +150 -0
- package/dist/components/content/listing.js.map +1 -0
- package/dist/components/content/offer-fields.d.ts +8 -0
- package/dist/components/content/offer-fields.js +127 -0
- package/dist/components/content/offer-fields.js.map +1 -0
- package/dist/components/content/paywall.d.ts +53 -0
- package/dist/components/content/paywall.js +221 -0
- package/dist/components/content/paywall.js.map +1 -0
- package/dist/components/content/search.d.ts +27 -0
- package/dist/components/content/search.js +164 -0
- package/dist/components/content/search.js.map +1 -0
- package/dist/components/groups/banner.d.ts +51 -0
- package/dist/components/groups/banner.js +194 -0
- package/dist/components/groups/banner.js.map +1 -0
- package/dist/components/groups/directory.d.ts +37 -0
- package/dist/components/groups/directory.js +117 -0
- package/dist/components/groups/directory.js.map +1 -0
- package/dist/components/groups/editor.d.ts +44 -0
- package/dist/components/groups/editor.js +860 -0
- package/dist/components/groups/editor.js.map +1 -0
- package/dist/components/groups/fields.d.ts +13 -0
- package/dist/components/groups/fields.js +68 -0
- package/dist/components/groups/fields.js.map +1 -0
- package/dist/components/groups/header.d.ts +25 -0
- package/dist/components/groups/header.js +131 -0
- package/dist/components/groups/header.js.map +1 -0
- package/dist/components/groups/index.d.ts +6 -0
- package/dist/components/groups/memberships.d.ts +55 -0
- package/dist/components/groups/memberships.js +527 -0
- package/dist/components/groups/memberships.js.map +1 -0
- package/dist/components/groups/parts.d.ts +49 -0
- package/dist/components/groups/parts.js +172 -0
- package/dist/components/groups/parts.js.map +1 -0
- package/dist/components/media-folder-editor.js +153 -152
- package/dist/components/media-folder-editor.js.map +1 -1
- package/dist/components/social/comments.d.ts +7 -5
- package/dist/components/social/comments.js +6 -2
- package/dist/components/social/comments.js.map +1 -1
- package/dist/components/social/engagement.d.ts +4 -3
- package/dist/components/social/engagement.js.map +1 -1
- package/dist/components/social/moderation.d.ts +1 -1
- package/dist/components/social/moderation.js +3 -3
- package/dist/components/social/moderation.js.map +1 -1
- package/dist/editor/rich-text-editor.d.ts +4 -4
- package/dist/editor/rich-text-editor.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +23 -9
- package/dist/locales/admin/de.js +5 -66
- package/dist/locales/admin/de.js.map +1 -1
- package/dist/locales/admin/en.d.ts +5 -66
- package/dist/locales/admin/en.js +19 -80
- package/dist/locales/admin/en.js.map +1 -1
- package/dist/locales/admin/es.js +5 -66
- package/dist/locales/admin/es.js.map +1 -1
- package/dist/locales/admin/ja.js +5 -66
- package/dist/locales/admin/ja.js.map +1 -1
- package/dist/locales/admin/ko.js +5 -66
- package/dist/locales/admin/ko.js.map +1 -1
- package/dist/locales/admin/zh.js +5 -66
- package/dist/locales/admin/zh.js.map +1 -1
- package/dist/locales/content/de.d.ts +2 -0
- package/dist/locales/content/de.js +98 -0
- package/dist/locales/content/de.js.map +1 -0
- package/dist/locales/content/en.d.ts +93 -0
- package/dist/locales/content/en.js +98 -0
- package/dist/locales/content/en.js.map +1 -0
- package/dist/locales/content/es.d.ts +2 -0
- package/dist/locales/content/es.js +98 -0
- package/dist/locales/content/es.js.map +1 -0
- package/dist/locales/content/ja.d.ts +2 -0
- package/dist/locales/content/ja.js +98 -0
- package/dist/locales/content/ja.js.map +1 -0
- package/dist/locales/content/ko.d.ts +2 -0
- package/dist/locales/content/ko.js +98 -0
- package/dist/locales/content/ko.js.map +1 -0
- package/dist/locales/content/zh.d.ts +2 -0
- package/dist/locales/content/zh.js +98 -0
- package/dist/locales/content/zh.js.map +1 -0
- package/dist/locales/de.js +11 -2
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/discovery/de.d.ts +2 -0
- package/dist/locales/discovery/de.js +68 -0
- package/dist/locales/discovery/de.js.map +1 -0
- package/dist/locales/discovery/en.d.ts +63 -0
- package/dist/locales/discovery/en.js +68 -0
- package/dist/locales/discovery/en.js.map +1 -0
- package/dist/locales/discovery/es.d.ts +2 -0
- package/dist/locales/discovery/es.js +68 -0
- package/dist/locales/discovery/es.js.map +1 -0
- package/dist/locales/discovery/ja.d.ts +2 -0
- package/dist/locales/discovery/ja.js +68 -0
- package/dist/locales/discovery/ja.js.map +1 -0
- package/dist/locales/discovery/ko.d.ts +2 -0
- package/dist/locales/discovery/ko.js +68 -0
- package/dist/locales/discovery/ko.js.map +1 -0
- package/dist/locales/discovery/zh.d.ts +2 -0
- package/dist/locales/discovery/zh.js +68 -0
- package/dist/locales/discovery/zh.js.map +1 -0
- package/dist/locales/en.d.ts +288 -67
- package/dist/locales/en.js +11 -2
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +11 -2
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/groups/de.d.ts +2 -0
- package/dist/locales/groups/de.js +133 -0
- package/dist/locales/groups/de.js.map +1 -0
- package/dist/locales/groups/en.d.ts +128 -0
- package/dist/locales/groups/en.js +133 -0
- package/dist/locales/groups/en.js.map +1 -0
- package/dist/locales/groups/es.d.ts +2 -0
- package/dist/locales/groups/es.js +133 -0
- package/dist/locales/groups/es.js.map +1 -0
- package/dist/locales/groups/ja.d.ts +2 -0
- package/dist/locales/groups/ja.js +133 -0
- package/dist/locales/groups/ja.js.map +1 -0
- package/dist/locales/groups/ko.d.ts +2 -0
- package/dist/locales/groups/ko.js +133 -0
- package/dist/locales/groups/ko.js.map +1 -0
- package/dist/locales/groups/zh.d.ts +2 -0
- package/dist/locales/groups/zh.js +133 -0
- package/dist/locales/groups/zh.js.map +1 -0
- package/dist/locales/ja.js +11 -2
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.js +11 -2
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/social/de.js +2 -1
- package/dist/locales/social/de.js.map +1 -1
- package/dist/locales/social/en.d.ts +2 -1
- package/dist/locales/social/en.js +2 -1
- package/dist/locales/social/en.js.map +1 -1
- package/dist/locales/social/es.js +2 -1
- package/dist/locales/social/es.js.map +1 -1
- package/dist/locales/social/ja.js +2 -1
- package/dist/locales/social/ja.js.map +1 -1
- package/dist/locales/social/ko.js +2 -1
- package/dist/locales/social/ko.js.map +1 -1
- package/dist/locales/social/zh.js +2 -1
- package/dist/locales/social/zh.js.map +1 -1
- package/dist/locales/zh.js +11 -2
- package/dist/locales/zh.js.map +1 -1
- package/dist/react/admin.d.ts +1 -1
- package/dist/react/admin.js +8 -6
- package/dist/react/admin.js.map +1 -1
- package/dist/react/comments.d.ts +9 -7
- package/dist/react/comments.js +42 -27
- package/dist/react/comments.js.map +1 -1
- package/dist/react/contents.d.ts +57 -0
- package/dist/react/contents.js +214 -0
- package/dist/react/contents.js.map +1 -0
- package/dist/react/context.d.ts +1 -1
- package/dist/react/context.js.map +1 -1
- package/dist/react/crop.js +45 -44
- package/dist/react/crop.js.map +1 -1
- package/dist/react/detail.d.ts +30 -0
- package/dist/react/detail.js +42 -0
- package/dist/react/detail.js.map +1 -0
- package/dist/react/discovery.d.ts +138 -0
- package/dist/react/discovery.js +299 -0
- package/dist/react/discovery.js.map +1 -0
- package/dist/react/engagement.d.ts +5 -5
- package/dist/react/engagement.js +55 -41
- package/dist/react/engagement.js.map +1 -1
- package/dist/react/folder.js +54 -53
- package/dist/react/folder.js.map +1 -1
- package/dist/react/groups.d.ts +115 -0
- package/dist/react/groups.js +229 -0
- package/dist/react/groups.js.map +1 -0
- package/dist/react/index.d.ts +5 -1
- package/dist/react/public.d.ts +6 -5
- package/dist/react/public.js +19 -22
- package/dist/react/public.js.map +1 -1
- package/dist/react/read.js +105 -106
- package/dist/react/read.js.map +1 -1
- package/dist/react/resources.d.ts +2 -2
- package/dist/react/resources.js +69 -40
- package/dist/react/resources.js.map +1 -1
- package/dist/react/store.js +41 -39
- package/dist/react/store.js.map +1 -1
- package/dist/react/upload.js +54 -53
- package/dist/react/upload.js.map +1 -1
- package/dist/react/use-resource.d.ts +2 -1
- package/dist/react/use-resource.js +1 -0
- package/dist/react/use-resource.js.map +1 -1
- package/dist/react/versions.d.ts +57 -0
- package/dist/react/versions.js +94 -0
- package/dist/react/versions.js.map +1 -0
- package/dist/react/video.js +87 -86
- package/dist/react/video.js.map +1 -1
- package/dist/react.js +9 -5
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/client/content/posts.d.ts +0 -52
- package/dist/client/content/posts.js +0 -84
- package/dist/client/content/posts.js.map +0 -1
- package/dist/client/taxonomy.d.ts +0 -34
- package/dist/client/taxonomy.js +0 -84
- package/dist/client/taxonomy.js.map +0 -1
- package/dist/components/admin/post-manager.d.ts +0 -45
- package/dist/components/admin/post-manager.js +0 -602
- package/dist/components/admin/post-manager.js.map +0 -1
- package/dist/components/admin/taxonomy-manager.d.ts +0 -54
- package/dist/components/admin/taxonomy-manager.js +0 -976
- package/dist/components/admin/taxonomy-manager.js.map +0 -1
- package/dist/react/posts.d.ts +0 -61
- package/dist/react/posts.js +0 -183
- package/dist/react/posts.js.map +0 -1
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
/** Content ids are canonical lowercase UUIDv7s (contentref.ValidateID). */
|
|
2
2
|
export declare const isContentId: (id: string) => boolean;
|
|
3
|
+
/** An item's identity: kind, id and, for a content's version, the version. */
|
|
4
|
+
export declare const itemKey: (ref: {
|
|
5
|
+
kind: string;
|
|
6
|
+
id: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
/** An item's ref and nothing else: kind, id and its version when it names one. */
|
|
10
|
+
export declare const itemRef: (ref: {
|
|
11
|
+
kind: string;
|
|
12
|
+
id: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
}) => {
|
|
15
|
+
kind: string;
|
|
16
|
+
id: string;
|
|
17
|
+
version: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: string;
|
|
20
|
+
id: string;
|
|
21
|
+
version?: undefined;
|
|
22
|
+
};
|
|
23
|
+
/** Both refs name the same item (a version is its own item). */
|
|
24
|
+
export declare const sameItem: (a: {
|
|
25
|
+
kind: string;
|
|
26
|
+
id: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
}, b: {
|
|
29
|
+
kind: string;
|
|
30
|
+
id: string;
|
|
31
|
+
version?: string;
|
|
32
|
+
}) => boolean;
|
|
3
33
|
/** Refuses a ref whose id ContentKit would reject, before any request. */
|
|
4
34
|
export declare function checkRef(ref: {
|
|
5
35
|
id: string;
|
package/dist/client/media/ref.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { ContentKitError as e } from "../errors.js";
|
|
2
2
|
//#region src/client/media/ref.ts
|
|
3
|
-
var t = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, n = (e) => t.test(e)
|
|
4
|
-
|
|
3
|
+
var t = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, n = (e) => t.test(e), r = (e) => e.version ? `${e.kind}/${e.id}/${e.version}` : `${e.kind}/${e.id}`, i = (e) => e.version ? {
|
|
4
|
+
kind: e.kind,
|
|
5
|
+
id: e.id,
|
|
6
|
+
version: e.version
|
|
7
|
+
} : {
|
|
8
|
+
kind: e.kind,
|
|
9
|
+
id: e.id
|
|
10
|
+
}, a = (e, t) => e.kind === t.kind && e.id === t.id && (e.version ?? "") === (t.version ?? "");
|
|
11
|
+
function o(t) {
|
|
5
12
|
if (t && !n(t.id)) throw new e("invalid_request", `content id must be a canonical UUIDv7, got "${t.id}"`);
|
|
6
13
|
}
|
|
7
14
|
//#endregion
|
|
8
|
-
export {
|
|
15
|
+
export { o as checkRef, n as isContentId, r as itemKey, i as itemRef, a as sameItem };
|
|
9
16
|
|
|
10
17
|
//# sourceMappingURL=ref.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","names":[],"sources":["../../../src/client/media/ref.ts"],"sourcesContent":["import { ContentKitError } from \"../errors.js\";\n\nconst contentId = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;\n\n/** Content ids are canonical lowercase UUIDv7s (contentref.ValidateID). */\nexport const isContentId = (id: string) => contentId.test(id);\n\n/** Refuses a ref whose id ContentKit would reject, before any request. */\nexport function checkRef(ref: { id: string } | undefined) {\n if (ref && !isContentId(ref.id)) throw new ContentKitError(\"invalid_request\", `content id must be a canonical UUIDv7, got \"${ref.id}\"`);\n}\n"],"mappings":";;AAEA,IAAM,IAAY,yEAGL,KAAe,MAAe,EAAU,KAAK,CAAE;
|
|
1
|
+
{"version":3,"file":"ref.js","names":[],"sources":["../../../src/client/media/ref.ts"],"sourcesContent":["import { ContentKitError } from \"../errors.js\";\n\nconst contentId = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;\n\n/** Content ids are canonical lowercase UUIDv7s (contentref.ValidateID). */\nexport const isContentId = (id: string) => contentId.test(id);\n\n/** An item's identity: kind, id and, for a content's version, the version. */\nexport const itemKey = (ref: { kind: string; id: string; version?: string }) => (ref.version ? `${ref.kind}/${ref.id}/${ref.version}` : `${ref.kind}/${ref.id}`);\n\n/** An item's ref and nothing else: kind, id and its version when it names one. */\nexport const itemRef = (ref: { kind: string; id: string; version?: string }) =>\n ref.version ? { kind: ref.kind, id: ref.id, version: ref.version } : { kind: ref.kind, id: ref.id };\n\n/** Both refs name the same item (a version is its own item). */\nexport const sameItem = (a: { kind: string; id: string; version?: string }, b: { kind: string; id: string; version?: string }) =>\n a.kind === b.kind && a.id === b.id && (a.version ?? \"\") === (b.version ?? \"\");\n\n/** Refuses a ref whose id ContentKit would reject, before any request. */\nexport function checkRef(ref: { id: string } | undefined) {\n if (ref && !isContentId(ref.id)) throw new ContentKitError(\"invalid_request\", `content id must be a canonical UUIDv7, got \"${ref.id}\"`);\n}\n"],"mappings":";;AAEA,IAAM,IAAY,yEAGL,KAAe,MAAe,EAAU,KAAK,CAAE,GAG/C,KAAW,MAAyD,EAAI,UAAU,GAAG,EAAI,KAAK,GAAG,EAAI,GAAG,GAAG,EAAI,YAAY,GAAG,EAAI,KAAK,GAAG,EAAI,MAG9I,KAAW,MACtB,EAAI,UAAU;CAAE,MAAM,EAAI;CAAM,IAAI,EAAI;CAAI,SAAS,EAAI;AAAQ,IAAI;CAAE,MAAM,EAAI;CAAM,IAAI,EAAI;AAAG,GAGvF,KAAY,GAAmD,MAC1E,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,SAAS,EAAE,WAAW;AAG5E,SAAgB,EAAS,GAAiC;CACxD,IAAI,KAAO,CAAC,EAAY,EAAI,EAAE,GAAG,MAAM,IAAI,EAAgB,mBAAmB,+CAA+C,EAAI,GAAG,EAAE;AACxI"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GroupJoin, LibraryPage, Offer, OfferPage, Terms } from './generated/wire.js';
|
|
2
|
+
import { Http } from './http.js';
|
|
3
|
+
/**
|
|
4
|
+
* Offers: content, versions and groups put on sale (their creators, owner
|
|
5
|
+
* group editors and root:offers:write holders), free group joins and the
|
|
6
|
+
* reader's library.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OffersClient {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: Http);
|
|
11
|
+
/** Puts a content (or one version) on sale, or reprices it: a new price, the old one archived. */
|
|
12
|
+
sell(target: {
|
|
13
|
+
content: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
}, terms: Terms): Promise<Offer>;
|
|
16
|
+
/** Takes it off sale; buyers keep what they bought. */
|
|
17
|
+
withdraw(target: {
|
|
18
|
+
content: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
}): Promise<Offer>;
|
|
21
|
+
/** Sells a group: its key opens every member. */
|
|
22
|
+
sellGroup(id: string, terms: Terms): Promise<Offer>;
|
|
23
|
+
withdrawGroup(id: string): Promise<Offer>;
|
|
24
|
+
/** Joins a free group (or leaves it): its key granted to the caller. */
|
|
25
|
+
join(id: string, member?: boolean): Promise<GroupJoin>;
|
|
26
|
+
/** What the reader bought, a cursor page at a time. */
|
|
27
|
+
library(q?: {
|
|
28
|
+
language?: string;
|
|
29
|
+
cursor?: string;
|
|
30
|
+
limit?: number;
|
|
31
|
+
}, signal?: AbortSignal): Promise<LibraryPage>;
|
|
32
|
+
/** Staff: every offer, by state or not yet synced to billing. */
|
|
33
|
+
list(q?: {
|
|
34
|
+
state?: "active" | "withdrawn";
|
|
35
|
+
unsynced?: boolean;
|
|
36
|
+
cursor?: string;
|
|
37
|
+
limit?: number;
|
|
38
|
+
}, signal?: AbortSignal): Promise<OfferPage>;
|
|
39
|
+
private write;
|
|
40
|
+
private writeGroup;
|
|
41
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { call as e } from "./route.js";
|
|
2
|
+
//#region src/client/offers.ts
|
|
3
|
+
var t = class {
|
|
4
|
+
http;
|
|
5
|
+
constructor(e) {
|
|
6
|
+
this.http = e;
|
|
7
|
+
}
|
|
8
|
+
sell(t, n) {
|
|
9
|
+
return this.write(t.content, t.version ? e(this.http, "PUT", "/contents/{id}/versions/{vid}/offer", {
|
|
10
|
+
params: {
|
|
11
|
+
id: t.content,
|
|
12
|
+
vid: t.version
|
|
13
|
+
},
|
|
14
|
+
body: n
|
|
15
|
+
}) : e(this.http, "PUT", "/contents/{id}/offer", {
|
|
16
|
+
params: { id: t.content },
|
|
17
|
+
body: n
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
withdraw(t) {
|
|
21
|
+
return this.write(t.content, t.version ? e(this.http, "DELETE", "/contents/{id}/versions/{vid}/offer", { params: {
|
|
22
|
+
id: t.content,
|
|
23
|
+
vid: t.version
|
|
24
|
+
} }) : e(this.http, "DELETE", "/contents/{id}/offer", { params: { id: t.content } }));
|
|
25
|
+
}
|
|
26
|
+
sellGroup(t, n) {
|
|
27
|
+
return this.writeGroup(e(this.http, "PUT", "/groups/{id}/offer", {
|
|
28
|
+
params: { id: t },
|
|
29
|
+
body: n
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
withdrawGroup(t) {
|
|
33
|
+
return this.writeGroup(e(this.http, "DELETE", "/groups/{id}/offer", { params: { id: t } }));
|
|
34
|
+
}
|
|
35
|
+
async join(t, n = !0) {
|
|
36
|
+
let r = this.http.captureChanges(), i = await e(this.http, n ? "POST" : "DELETE", "/groups/{id}/join", { params: { id: t } });
|
|
37
|
+
return r({ type: "access.changed" }), i;
|
|
38
|
+
}
|
|
39
|
+
library(t = {}, n) {
|
|
40
|
+
return e(this.http, "GET", "/me/library", {
|
|
41
|
+
query: t,
|
|
42
|
+
signal: n
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
list(t = {}, n) {
|
|
46
|
+
return e(this.http, "GET", "/offers", {
|
|
47
|
+
query: t,
|
|
48
|
+
signal: n
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async write(e, t) {
|
|
52
|
+
let n = this.http.captureChanges(), r = await t;
|
|
53
|
+
return n({
|
|
54
|
+
type: "content.changed",
|
|
55
|
+
id: e
|
|
56
|
+
}), r;
|
|
57
|
+
}
|
|
58
|
+
async writeGroup(e) {
|
|
59
|
+
let t = this.http.captureChanges(), n = await e;
|
|
60
|
+
return t({ type: "groups.changed" }), n;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { t as OffersClient };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=offers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offers.js","names":[],"sources":["../../src/client/offers.ts"],"sourcesContent":["import type { GroupJoin, LibraryPage, Offer, OfferPage, Terms } from \"./generated/wire.js\";\nimport type { Http } from \"./http.js\";\nimport { call } from \"./route.js\";\n\n/**\n * Offers: content, versions and groups put on sale (their creators, owner\n * group editors and root:offers:write holders), free group joins and the\n * reader's library.\n */\nexport class OffersClient {\n constructor(private readonly http: Http) {}\n\n /** Puts a content (or one version) on sale, or reprices it: a new price, the old one archived. */\n sell(target: { content: string; version?: string }, terms: Terms): Promise<Offer> {\n return this.write(\n target.content,\n target.version\n ? call(this.http, \"PUT\", \"/contents/{id}/versions/{vid}/offer\", { params: { id: target.content, vid: target.version }, body: terms })\n : call(this.http, \"PUT\", \"/contents/{id}/offer\", { params: { id: target.content }, body: terms }),\n );\n }\n /** Takes it off sale; buyers keep what they bought. */\n withdraw(target: { content: string; version?: string }): Promise<Offer> {\n return this.write(\n target.content,\n target.version\n ? call(this.http, \"DELETE\", \"/contents/{id}/versions/{vid}/offer\", { params: { id: target.content, vid: target.version } })\n : call(this.http, \"DELETE\", \"/contents/{id}/offer\", { params: { id: target.content } }),\n );\n }\n /** Sells a group: its key opens every member. */\n sellGroup(id: string, terms: Terms): Promise<Offer> {\n return this.writeGroup(call(this.http, \"PUT\", \"/groups/{id}/offer\", { params: { id }, body: terms }));\n }\n withdrawGroup(id: string): Promise<Offer> {\n return this.writeGroup(call(this.http, \"DELETE\", \"/groups/{id}/offer\", { params: { id } }));\n }\n /** Joins a free group (or leaves it): its key granted to the caller. */\n async join(id: string, member = true): Promise<GroupJoin> {\n const emit = this.http.captureChanges();\n const out: GroupJoin = await call(this.http, member ? \"POST\" : \"DELETE\", \"/groups/{id}/join\", { params: { id } });\n emit({ type: \"access.changed\" });\n return out;\n }\n /** What the reader bought, a cursor page at a time. */\n library(q: { language?: string; cursor?: string; limit?: number } = {}, signal?: AbortSignal): Promise<LibraryPage> {\n return call(this.http, \"GET\", \"/me/library\", { query: q, signal });\n }\n /** Staff: every offer, by state or not yet synced to billing. */\n list(q: { state?: \"active\" | \"withdrawn\"; unsynced?: boolean; cursor?: string; limit?: number } = {}, signal?: AbortSignal): Promise<OfferPage> {\n return call(this.http, \"GET\", \"/offers\", { query: q, signal });\n }\n\n private async write(content: string, p: Promise<Offer>): Promise<Offer> {\n const emit = this.http.captureChanges();\n const out = await p;\n emit({ type: \"content.changed\", id: content });\n return out;\n }\n\n private async writeGroup(p: Promise<Offer>): Promise<Offer> {\n const emit = this.http.captureChanges();\n const out = await p;\n emit({ type: \"groups.changed\" });\n return out;\n }\n}\n"],"mappings":";;AASA,IAAa,IAAb,MAA0B;CACK;CAA7B,YAAY,GAA6B;EAAZ,KAAA,OAAA;CAAa;CAG1C,KAAK,GAA+C,GAA8B;EAChF,OAAO,KAAK,MACV,EAAO,SACP,EAAO,UACH,EAAK,KAAK,MAAM,OAAO,uCAAuC;GAAE,QAAQ;IAAE,IAAI,EAAO;IAAS,KAAK,EAAO;GAAQ;GAAG,MAAM;EAAM,CAAC,IAClI,EAAK,KAAK,MAAM,OAAO,wBAAwB;GAAE,QAAQ,EAAE,IAAI,EAAO,QAAQ;GAAG,MAAM;EAAM,CAAC,CACpG;CACF;CAEA,SAAS,GAA+D;EACtE,OAAO,KAAK,MACV,EAAO,SACP,EAAO,UACH,EAAK,KAAK,MAAM,UAAU,uCAAuC,EAAE,QAAQ;GAAE,IAAI,EAAO;GAAS,KAAK,EAAO;EAAQ,EAAE,CAAC,IACxH,EAAK,KAAK,MAAM,UAAU,wBAAwB,EAAE,QAAQ,EAAE,IAAI,EAAO,QAAQ,EAAE,CAAC,CAC1F;CACF;CAEA,UAAU,GAAY,GAA8B;EAClD,OAAO,KAAK,WAAW,EAAK,KAAK,MAAM,OAAO,sBAAsB;GAAE,QAAQ,EAAE,MAAG;GAAG,MAAM;EAAM,CAAC,CAAC;CACtG;CACA,cAAc,GAA4B;EACxC,OAAO,KAAK,WAAW,EAAK,KAAK,MAAM,UAAU,sBAAsB,EAAE,QAAQ,EAAE,MAAG,EAAE,CAAC,CAAC;CAC5F;CAEA,MAAM,KAAK,GAAY,IAAS,IAA0B;EACxD,IAAM,IAAO,KAAK,KAAK,eAAe,GAChC,IAAiB,MAAM,EAAK,KAAK,MAAM,IAAS,SAAS,UAAU,qBAAqB,EAAE,QAAQ,EAAE,MAAG,EAAE,CAAC;EAEhH,OADA,EAAK,EAAE,MAAM,iBAAiB,CAAC,GACxB;CACT;CAEA,QAAQ,IAA4D,CAAC,GAAG,GAA4C;EAClH,OAAO,EAAK,KAAK,MAAM,OAAO,eAAe;GAAE,OAAO;GAAG;EAAO,CAAC;CACnE;CAEA,KAAK,IAA6F,CAAC,GAAG,GAA0C;EAC9I,OAAO,EAAK,KAAK,MAAM,OAAO,WAAW;GAAE,OAAO;GAAG;EAAO,CAAC;CAC/D;CAEA,MAAc,MAAM,GAAiB,GAAmC;EACtE,IAAM,IAAO,KAAK,KAAK,eAAe,GAChC,IAAM,MAAM;EAElB,OADA,EAAK;GAAE,MAAM;GAAmB,IAAI;EAAQ,CAAC,GACtC;CACT;CAEA,MAAc,WAAW,GAAmC;EAC1D,IAAM,IAAO,KAAK,KAAK,eAAe,GAChC,IAAM,MAAM;EAElB,OADA,EAAK,EAAE,MAAM,iBAAiB,CAAC,GACxB;CACT;AACF"}
|
package/dist/client/route.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface CallOptions<M extends Method, P extends string> {
|
|
|
23
23
|
query?: RouteQuery<M, P>;
|
|
24
24
|
body?: unknown;
|
|
25
25
|
signal?: AbortSignal;
|
|
26
|
+
/** Outlives the page (a beacon sent as it closes). */
|
|
27
|
+
keepalive?: boolean;
|
|
26
28
|
}
|
|
27
29
|
/** The URL of a catalog route: its module's mount, the path with params filled, then the query. */
|
|
28
30
|
export declare function routeURL<M extends Method, P extends RoutePath<M>>(http: Http, method: M, path: P, o?: Pick<CallOptions<M, P>, "params" | "query">): string;
|
package/dist/client/route.js
CHANGED
package/dist/client/route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","names":[],"sources":["../../src/client/route.ts"],"sourcesContent":["import { CONTENTKIT_ROUTES } from \"./generated/routes.js\";\nimport type { Http } from \"./http.js\";\n\ntype AnyRoute = (typeof CONTENTKIT_ROUTES)[number];\nexport type Method = AnyRoute[\"method\"];\n/** A route path the catalog declares for the method. */\nexport type RoutePath<M extends Method> = Extract<AnyRoute, { method: M }>[\"path\"];\ntype RouteOf<M extends Method, P extends string> = Extract<AnyRoute, { method: M; path: P }>;\n\ntype ParamNames<P extends string> = P extends `${string}{${infer K}}${infer R}` ? (K extends `${infer N}...` ? N : K) | ParamNames<R> : never;\n/** The path's {wildcards}, each a string value. */\nexport type PathParams<P extends string> = { [K in ParamNames<P>]: string };\n/** The query parameters the route declares. */\nexport type RouteQuery<M extends Method, P extends string> = Partial<Record<RouteOf<M, P>[\"query\"][number], QueryValue>>;\ntype QueryValue = string | number | boolean | null | undefined | readonly string[];\n\nexport interface CallOptions<M extends Method, P extends string> {\n params?: PathParams<P>;\n query?: RouteQuery<M, P>;\n body?: unknown;\n signal?: AbortSignal;\n}\n\nconst index = new Map<string, AnyRoute>(CONTENTKIT_ROUTES.map((r) => [`${r.method} ${r.path}`, r]));\n\n/** The URL of a catalog route: its module's mount, the path with params filled, then the query. */\nexport function routeURL<M extends Method, P extends RoutePath<M>>(http: Http, method: M, path: P, o: Pick<CallOptions<M, P>, \"params\" | \"query\"> = {}): string {\n return build(http, method, path, o.params as Record<string, string> | undefined, o.query as Record<string, QueryValue> | undefined);\n}\n\n/**\n * Calls a catalog route and resolves with its JSON body (undefined for 204);\n * the caller's declared type names it.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function call<M extends Method, P extends RoutePath<M>, T = any>(http: Http, method: M, path: P, o: CallOptions<M, P> = {}): Promise<T> {\n const url = build(http, method, path, o.params as Record<string, string> | undefined, o.query as Record<string, QueryValue> | undefined);\n return http.request<T>(url, { method, body: o.body, signal: o.signal });\n}\n\nfunction build(http: Http, method: string, path: string, params: Record<string, string> = {}, query: Record<string, QueryValue> = {}): string {\n const r = index.get(`${method} ${path}`);\n if (!r) throw new Error(`contentkit: no route ${method} ${path}`);\n const filled = path.replace(/\\{(\\w+)(\\.\\.\\.)?\\}/g, (_, name: string, rest?: string) => {\n const v = params[name];\n if (v === undefined || v === \"\") throw new Error(`contentkit: ${method} ${path} needs ${name}`);\n return rest ? v.split(\"/\").map(encodeURIComponent).join(\"/\") : encodeURIComponent(v);\n });\n const q = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (Array.isArray(v)) for (const x of v) q.append(k, x);\n else if (v !== undefined && v !== null && v !== \"\") q.set(k, String(v));\n }\n const s = q.toString();\n return http.mount(r.module) + filled + (s ? `?${s}` : \"\");\n}\n\n/** A page of a limit/offset list. */\nexport interface PageQuery {\n limit?: number;\n offset?: number;\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"route.js","names":[],"sources":["../../src/client/route.ts"],"sourcesContent":["import { CONTENTKIT_ROUTES } from \"./generated/routes.js\";\nimport type { Http } from \"./http.js\";\n\ntype AnyRoute = (typeof CONTENTKIT_ROUTES)[number];\nexport type Method = AnyRoute[\"method\"];\n/** A route path the catalog declares for the method. */\nexport type RoutePath<M extends Method> = Extract<AnyRoute, { method: M }>[\"path\"];\ntype RouteOf<M extends Method, P extends string> = Extract<AnyRoute, { method: M; path: P }>;\n\ntype ParamNames<P extends string> = P extends `${string}{${infer K}}${infer R}` ? (K extends `${infer N}...` ? N : K) | ParamNames<R> : never;\n/** The path's {wildcards}, each a string value. */\nexport type PathParams<P extends string> = { [K in ParamNames<P>]: string };\n/** The query parameters the route declares. */\nexport type RouteQuery<M extends Method, P extends string> = Partial<Record<RouteOf<M, P>[\"query\"][number], QueryValue>>;\ntype QueryValue = string | number | boolean | null | undefined | readonly string[];\n\nexport interface CallOptions<M extends Method, P extends string> {\n params?: PathParams<P>;\n query?: RouteQuery<M, P>;\n body?: unknown;\n signal?: AbortSignal;\n /** Outlives the page (a beacon sent as it closes). */\n keepalive?: boolean;\n}\n\nconst index = new Map<string, AnyRoute>(CONTENTKIT_ROUTES.map((r) => [`${r.method} ${r.path}`, r]));\n\n/** The URL of a catalog route: its module's mount, the path with params filled, then the query. */\nexport function routeURL<M extends Method, P extends RoutePath<M>>(http: Http, method: M, path: P, o: Pick<CallOptions<M, P>, \"params\" | \"query\"> = {}): string {\n return build(http, method, path, o.params as Record<string, string> | undefined, o.query as Record<string, QueryValue> | undefined);\n}\n\n/**\n * Calls a catalog route and resolves with its JSON body (undefined for 204);\n * the caller's declared type names it.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function call<M extends Method, P extends RoutePath<M>, T = any>(http: Http, method: M, path: P, o: CallOptions<M, P> = {}): Promise<T> {\n const url = build(http, method, path, o.params as Record<string, string> | undefined, o.query as Record<string, QueryValue> | undefined);\n return http.request<T>(url, { method, body: o.body, signal: o.signal, keepalive: o.keepalive });\n}\n\nfunction build(http: Http, method: string, path: string, params: Record<string, string> = {}, query: Record<string, QueryValue> = {}): string {\n const r = index.get(`${method} ${path}`);\n if (!r) throw new Error(`contentkit: no route ${method} ${path}`);\n const filled = path.replace(/\\{(\\w+)(\\.\\.\\.)?\\}/g, (_, name: string, rest?: string) => {\n const v = params[name];\n if (v === undefined || v === \"\") throw new Error(`contentkit: ${method} ${path} needs ${name}`);\n return rest ? v.split(\"/\").map(encodeURIComponent).join(\"/\") : encodeURIComponent(v);\n });\n const q = new URLSearchParams();\n for (const [k, v] of Object.entries(query)) {\n if (Array.isArray(v)) for (const x of v) q.append(k, x);\n else if (v !== undefined && v !== null && v !== \"\") q.set(k, String(v));\n }\n const s = q.toString();\n return http.mount(r.module) + filled + (s ? `?${s}` : \"\");\n}\n\n/** A page of a limit/offset list. */\nexport interface PageQuery {\n limit?: number;\n offset?: number;\n}\n"],"mappings":";;AAyBA,IAAM,IAAQ,IAAI,IAAsB,EAAkB,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;AAGlG,SAAgB,EAAmD,GAAY,GAAW,GAAS,IAAiD,CAAC,GAAW;CAC9J,OAAO,EAAM,GAAM,GAAQ,GAAM,EAAE,QAA8C,EAAE,KAA+C;AACpI;AAOA,SAAgB,EAAwD,GAAY,GAAW,GAAS,IAAuB,CAAC,GAAe;CAC7I,IAAM,IAAM,EAAM,GAAM,GAAQ,GAAM,EAAE,QAA8C,EAAE,KAA+C;CACvI,OAAO,EAAK,QAAW,GAAK;EAAE;EAAQ,MAAM,EAAE;EAAM,QAAQ,EAAE;EAAQ,WAAW,EAAE;CAAU,CAAC;AAChG;AAEA,SAAS,EAAM,GAAY,GAAgB,GAAc,IAAiC,CAAC,GAAG,IAAoC,CAAC,GAAW;CAC5I,IAAM,IAAI,EAAM,IAAI,GAAG,EAAO,GAAG,GAAM;CACvC,IAAI,CAAC,GAAG,MAAU,MAAM,wBAAwB,EAAO,GAAG,GAAM;CAChE,IAAM,IAAS,EAAK,QAAQ,wBAAwB,GAAG,GAAc,MAAkB;EACrF,IAAM,IAAI,EAAO;EACjB,IAAI,MAAM,KAAA,KAAa,MAAM,IAAI,MAAU,MAAM,eAAe,EAAO,GAAG,EAAK,SAAS,GAAM;EAC9F,OAAO,IAAO,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,KAAK,GAAG,IAAI,mBAAmB,CAAC;CACrF,CAAC,GACK,IAAI,IAAI,gBAAgB;CAC9B,KAAK,IAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,CAAK,GACvC,IAAI,MAAM,QAAQ,CAAC,GAAG,KAAK,IAAM,KAAK,GAAG,EAAE,OAAO,GAAG,CAAC;MACjD,AAAI,KAAyB,QAAQ,MAAM,MAAI,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;CAExE,IAAM,IAAI,EAAE,SAAS;CACrB,OAAO,EAAK,MAAM,EAAE,MAAM,IAAI,KAAU,IAAI,IAAI,MAAM;AACxD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ForkBody, Pending, ReaderMeta, ReaderPlan } from './generated/wire.js';
|
|
2
|
+
import { Http } from './http.js';
|
|
3
|
+
/** A version's answer while it is prepared (202). */
|
|
4
|
+
export declare const isPending: (x: unknown) => x is Pending;
|
|
5
|
+
/** Content versions: reader plans, reader metadata, forks and downloads. */
|
|
6
|
+
export declare class VersionsClient {
|
|
7
|
+
private readonly http;
|
|
8
|
+
constructor(http: Http);
|
|
9
|
+
/** The version's reader plan for this viewer; Pending while it has no current publication. */
|
|
10
|
+
reader(content: string, version: string, signal?: AbortSignal): Promise<ReaderPlan | Pending>;
|
|
11
|
+
/** Editors: the version's anchors and audio cues. */
|
|
12
|
+
setReader(content: string, version: string, meta: ReaderMeta): Promise<void>;
|
|
13
|
+
/** Editors: fills a version without media from a sibling, in a durable job. */
|
|
14
|
+
fork(content: string, version: string, body: ForkBody): Promise<Pending>;
|
|
15
|
+
/**
|
|
16
|
+
* The version's pages as a zip, charged to the viewer's download quota;
|
|
17
|
+
* Pending while it is prepared (ask again).
|
|
18
|
+
*/
|
|
19
|
+
download(content: string, version: string, signal?: AbortSignal): Promise<Blob | Pending>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ContentKitError as e } from "./errors.js";
|
|
2
|
+
import { call as t, routeURL as n } from "./route.js";
|
|
3
|
+
//#region src/client/versions.ts
|
|
4
|
+
var r = (e) => !!e && typeof e == "object" && "status" in e && !("pages" in e), i = class {
|
|
5
|
+
http;
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.http = e;
|
|
8
|
+
}
|
|
9
|
+
reader(e, n, r) {
|
|
10
|
+
return t(this.http, "GET", "/contents/{id}/versions/{version}/reader", {
|
|
11
|
+
params: {
|
|
12
|
+
id: e,
|
|
13
|
+
version: n
|
|
14
|
+
},
|
|
15
|
+
signal: r
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
setReader(e, n, r) {
|
|
19
|
+
return t(this.http, "PUT", "/contents/{id}/versions/{version}/reader", {
|
|
20
|
+
params: {
|
|
21
|
+
id: e,
|
|
22
|
+
version: n
|
|
23
|
+
},
|
|
24
|
+
body: r
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
fork(e, n, r) {
|
|
28
|
+
return t(this.http, "POST", "/contents/{id}/versions/{version}/fork", {
|
|
29
|
+
params: {
|
|
30
|
+
id: e,
|
|
31
|
+
version: n
|
|
32
|
+
},
|
|
33
|
+
body: r
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async download(t, i, a) {
|
|
37
|
+
let o = n(this.http, "GET", "/contents/{id}/versions/{version}/download", { params: {
|
|
38
|
+
id: t,
|
|
39
|
+
version: i
|
|
40
|
+
} }), s = await this.http.request(o, {
|
|
41
|
+
signal: a,
|
|
42
|
+
blob: !0
|
|
43
|
+
});
|
|
44
|
+
if (!s.type.startsWith("application/json")) return s;
|
|
45
|
+
let c = JSON.parse(await s.text());
|
|
46
|
+
if (r(c)) return c;
|
|
47
|
+
throw new e("internal_error", "unexpected download answer");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { i as VersionsClient, r as isPending };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.js","names":[],"sources":["../../src/client/versions.ts"],"sourcesContent":["import { ContentKitError } from \"./errors.js\";\nimport type { ForkBody, Pending, ReaderMeta, ReaderPlan } from \"./generated/wire.js\";\nimport type { Http } from \"./http.js\";\nimport { call, routeURL } from \"./route.js\";\n\n/** A version's answer while it is prepared (202). */\nexport const isPending = (x: unknown): x is Pending => !!x && typeof x === \"object\" && \"status\" in x && !(\"pages\" in x);\n\n/** Content versions: reader plans, reader metadata, forks and downloads. */\nexport class VersionsClient {\n constructor(private readonly http: Http) {}\n\n /** The version's reader plan for this viewer; Pending while it has no current publication. */\n reader(content: string, version: string, signal?: AbortSignal): Promise<ReaderPlan | Pending> {\n return call(this.http, \"GET\", \"/contents/{id}/versions/{version}/reader\", { params: { id: content, version }, signal });\n }\n /** Editors: the version's anchors and audio cues. */\n setReader(content: string, version: string, meta: ReaderMeta): Promise<void> {\n return call(this.http, \"PUT\", \"/contents/{id}/versions/{version}/reader\", { params: { id: content, version }, body: meta });\n }\n /** Editors: fills a version without media from a sibling, in a durable job. */\n fork(content: string, version: string, body: ForkBody): Promise<Pending> {\n return call(this.http, \"POST\", \"/contents/{id}/versions/{version}/fork\", { params: { id: content, version }, body });\n }\n /**\n * The version's pages as a zip, charged to the viewer's download quota;\n * Pending while it is prepared (ask again).\n */\n async download(content: string, version: string, signal?: AbortSignal): Promise<Blob | Pending> {\n const url = routeURL(this.http, \"GET\", \"/contents/{id}/versions/{version}/download\", { params: { id: content, version } });\n const out = await this.http.request<Blob>(url, { signal, blob: true });\n if (!out.type.startsWith(\"application/json\")) return out;\n const body: unknown = JSON.parse(await out.text());\n if (isPending(body)) return body;\n throw new ContentKitError(\"internal_error\", \"unexpected download answer\");\n }\n}\n"],"mappings":";;;AAMA,IAAa,KAAa,MAA6B,CAAC,CAAC,KAAK,OAAO,KAAM,YAAY,YAAY,KAAK,EAAE,WAAW,IAGxG,IAAb,MAA4B;CACG;CAA7B,YAAY,GAA6B;EAAZ,KAAA,OAAA;CAAa;CAG1C,OAAO,GAAiB,GAAiB,GAAqD;EAC5F,OAAO,EAAK,KAAK,MAAM,OAAO,4CAA4C;GAAE,QAAQ;IAAE,IAAI;IAAS;GAAQ;GAAG;EAAO,CAAC;CACxH;CAEA,UAAU,GAAiB,GAAiB,GAAiC;EAC3E,OAAO,EAAK,KAAK,MAAM,OAAO,4CAA4C;GAAE,QAAQ;IAAE,IAAI;IAAS;GAAQ;GAAG,MAAM;EAAK,CAAC;CAC5H;CAEA,KAAK,GAAiB,GAAiB,GAAkC;EACvE,OAAO,EAAK,KAAK,MAAM,QAAQ,0CAA0C;GAAE,QAAQ;IAAE,IAAI;IAAS;GAAQ;GAAG;EAAK,CAAC;CACrH;CAKA,MAAM,SAAS,GAAiB,GAAiB,GAA+C;EAC9F,IAAM,IAAM,EAAS,KAAK,MAAM,OAAO,8CAA8C,EAAE,QAAQ;GAAE,IAAI;GAAS;EAAQ,EAAE,CAAC,GACnH,IAAM,MAAM,KAAK,KAAK,QAAc,GAAK;GAAE;GAAQ,MAAM;EAAK,CAAC;EACrE,IAAI,CAAC,EAAI,KAAK,WAAW,kBAAkB,GAAG,OAAO;EACrD,IAAM,IAAgB,KAAK,MAAM,MAAM,EAAI,KAAK,CAAC;EACjD,IAAI,EAAU,CAAI,GAAG,OAAO;EAC5B,MAAM,IAAI,EAAgB,kBAAkB,4BAA4B;CAC1E;AACF"}
|
package/dist/client.js
CHANGED
|
@@ -3,33 +3,38 @@ import { CLIENT_ERROR_CODES as i, ContentKitError as a, ERROR_CODES as o, failur
|
|
|
3
3
|
import { fill as d, publicRenditions as f, publicURL as p, srcSet as m } from "./client/public.js";
|
|
4
4
|
import { aspectOf as h, ratio as g } from "./client/aspect.js";
|
|
5
5
|
import { call as _, routeURL as v } from "./client/route.js";
|
|
6
|
-
import { checkRef as y, isContentId as b } from "./client/media/ref.js";
|
|
7
|
-
import { MediaApi as
|
|
8
|
-
import { MAX_PART_SIZE as
|
|
9
|
-
import { sha256Hex as
|
|
10
|
-
import { Pacer as
|
|
11
|
-
import { defaultTransport as
|
|
12
|
-
import { MediaClient as
|
|
13
|
-
import { acceptOf as
|
|
14
|
-
import { centeredCrop as
|
|
15
|
-
import { encodeRemaining as
|
|
16
|
-
import { ItemUploadQueue as
|
|
17
|
-
import { decodeImage as
|
|
18
|
-
import { READ_CHUNK as
|
|
19
|
-
import { ABR_DEFAULTS as
|
|
20
|
-
import { formatDuration as
|
|
21
|
-
import { PLAYBACK_SPEEDS as
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
6
|
+
import { checkRef as y, isContentId as b, itemKey as x, sameItem as S } from "./client/media/ref.js";
|
|
7
|
+
import { MediaApi as C } from "./client/media/api.js";
|
|
8
|
+
import { MAX_PART_SIZE as w, MAX_SINGLE_PUT as T, MIN_PART_SIZE as E } from "./client/generated/wire.js";
|
|
9
|
+
import { sha256Hex as D } from "./client/media/hash.js";
|
|
10
|
+
import { Pacer as O } from "./client/media/pacer.js";
|
|
11
|
+
import { defaultTransport as k, fetchTransport as A, xhrTransport as j } from "./client/media/transport.js";
|
|
12
|
+
import { MediaClient as M, backoff as N, samePath as P, stem as F } from "./client/media/client.js";
|
|
13
|
+
import { acceptOf as I, defaultImage as L, filesFor as R, isPattern as z, ratioLabel as B, ruleDir as V, ruleFor as H, screenFiles as U, uniqueName as W, uploadRules as G, withMediaType as K } from "./client/media/rules.js";
|
|
14
|
+
import { centeredCrop as q, constrainCrop as J, editOf as Y, editedSize as X, fromRotated as Z, rotation as Q, sameEdit as $, toOriginal as ee, toRotated as te } from "./client/crop.js";
|
|
15
|
+
import { encodeRemaining as ne } from "./client/media/encode.js";
|
|
16
|
+
import { ItemUploadQueue as re } from "./client/media/queue.js";
|
|
17
|
+
import { decodeImage as ie, isAnimatedImage as ae } from "./client/image.js";
|
|
18
|
+
import { READ_CHUNK as oe, chunkOffsets as se, isProcessing as ce, mergeReads as le, processing as ue } from "./client/media/windows.js";
|
|
19
|
+
import { ABR_DEFAULTS as de, NETWORK_FAILURES_BEFORE_ERROR as fe, REFRESH_BEFORE_EXPIRY as pe, abrHlsConfig as me, capRung as he, classifyHlsError as ge, classifyMediaError as _e, expiryDelay as ve, hlsConfig as ye, initialEstimate as be, refreshable as xe, startRung as Se, statusKind as Ce } from "./client/playback.js";
|
|
20
|
+
import { formatDuration as we, galleryItems as Te, isAudioType as Ee, isImageType as De, isSubtitleType as Oe, isVideoType as ke, stageAspect as Ae } from "./client/gallery.js";
|
|
21
|
+
import { PLAYBACK_SPEEDS as je, PLAYER_TRACKS_KEY as Me, PLAYER_VOLUME_KEY as Ne, parseSpriteVtt as Pe, playerKeyAction as Fe, resumeAt as Ie } from "./client/player.js";
|
|
22
|
+
import { reactionVerb as Le, sameTarget as Re } from "./client/content/types.js";
|
|
23
|
+
import { CatalogClient as ze } from "./client/catalog.js";
|
|
24
|
+
import { CodesClient as Be } from "./client/codes.js";
|
|
25
|
+
import { BODY_SUFFIX as Ve, ContentsClient as He, IMAGE_SCHEME as Ue, imageRef as We, imageRefs as Ge } from "./client/contents.js";
|
|
26
|
+
import { BansClient as Ke } from "./client/content/bans.js";
|
|
27
|
+
import { CommentsClient as qe } from "./client/content/comments.js";
|
|
28
|
+
import { Beacons as Je, eventId as Ye, readerSession as Xe } from "./client/beacons.js";
|
|
29
|
+
import { DiscoveryClient as Ze } from "./client/discovery.js";
|
|
30
|
+
import { FavoritesClient as Qe } from "./client/content/favorites.js";
|
|
31
|
+
import { ModerationClient as $e } from "./client/content/moderation.js";
|
|
32
|
+
import { PollsClient as et } from "./client/content/polls.js";
|
|
33
|
+
import { ReactionsClient as tt } from "./client/content/reactions.js";
|
|
34
|
+
import { GroupsClient as nt } from "./client/groups.js";
|
|
35
|
+
import { OffersClient as rt } from "./client/offers.js";
|
|
36
|
+
import { VersionsClient as it, isPending as at } from "./client/versions.js";
|
|
37
|
+
import { NotificationsClient as ot } from "./client/notifications.js";
|
|
38
|
+
import { createContentKitClient as st } from "./client/client.js";
|
|
39
|
+
import { LETTERS as ct, attributeInput as lt, fold as ut, fromLocalInput as dt, humanize as ft, letterOf as pt, parseAttribute as mt, parseAttributes as ht, slugify as gt, toLocalInput as _t } from "./client/group-fields.js";
|
|
40
|
+
export { de as ABR_DEFAULTS, Ve as BODY_SUFFIX, Ke as BansClient, Je as Beacons, i as CLIENT_ERROR_CODES, ze as CatalogClient, Be as CodesClient, qe as CommentsClient, a as ContentKitError, He as ContentsClient, e as DEFAULT_DENSITY, Ze as DiscoveryClient, o as ERROR_CODES, Qe as FavoritesClient, nt as GroupsClient, Ue as IMAGE_SCHEME, re as ItemUploadQueue, ct as LETTERS, w as MAX_PART_SIZE, T as MAX_SINGLE_PUT, E as MIN_PART_SIZE, C as MediaApi, M as MediaClient, $e as ModerationClient, fe as NETWORK_FAILURES_BEFORE_ERROR, ot as NotificationsClient, rt as OffersClient, je as PLAYBACK_SPEEDS, Me as PLAYER_TRACKS_KEY, Ne as PLAYER_VOLUME_KEY, O as Pacer, et as PollsClient, oe as READ_CHUNK, pe as REFRESH_BEFORE_EXPIRY, tt as ReactionsClient, it as VersionsClient, me as abrHlsConfig, I as acceptOf, h as aspectOf, lt as attributeInput, N as backoff, _ as call, he as capRung, q as centeredCrop, y as checkRef, se as chunkOffsets, ge as classifyHlsError, _e as classifyMediaError, J as constrainCrop, st as createContentKitClient, ie as decodeImage, L as defaultImage, k as defaultTransport, t as densityFor, Y as editOf, X as editedSize, ne as encodeRemaining, Ye as eventId, ve as expiryDelay, s as failureError, A as fetchTransport, R as filesFor, d as fill, ut as fold, we as formatDuration, dt as fromLocalInput, Z as fromRotated, Te as galleryItems, ye as hlsConfig, ft as humanize, We as imageRef, Ge as imageRefs, be as initialEstimate, ae as isAnimatedImage, Ee as isAudioType, b as isContentId, c as isContentKitError, De as isImageType, z as isPattern, at as isPending, ce as isProcessing, Oe as isSubtitleType, ke as isVideoType, x as itemKey, pt as letterOf, le as mergeReads, mt as parseAttribute, ht as parseAttributes, Pe as parseSpriteVtt, n as pickRendition, Fe as playerKeyAction, ue as processing, f as publicRenditions, p as publicURL, g as ratio, B as ratioLabel, Le as reactionVerb, l as readContentKitError, Xe as readerSession, xe as refreshable, Ie as resumeAt, Q as rotation, v as routeURL, V as ruleDir, H as ruleFor, $ as sameEdit, S as sameItem, P as samePath, Re as sameTarget, U as screenFiles, D as sha256Hex, gt as slugify, r as sortRenditions, m as srcSet, Ae as stageAspect, Se as startRung, Ce as statusKind, F as stem, u as toContentKitError, _t as toLocalInput, ee as toOriginal, te as toRotated, W as uniqueName, G as uploadRules, K as withMediaType, j as xhrTransport };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ContentKitClient } from '../../client/client.js';
|
|
3
|
+
import { Content } from '../../client/generated/wire.js';
|
|
4
|
+
import { FlowClientOptions, StaffAccess } from '../../react/admin.js';
|
|
5
|
+
import { ContentKitErrorHandler } from '../../react/context.js';
|
|
6
|
+
import { Labels } from '../groups/parts.js';
|
|
7
|
+
import { AdminFlowProps, AdminRouteProps } from './shell.js';
|
|
8
|
+
type Choice = string | {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
/** What ContentManager hands its body editor. */
|
|
13
|
+
export interface BodyEditorProps {
|
|
14
|
+
/** The body as HTML, its images at URLs that show them now. */
|
|
15
|
+
value: string;
|
|
16
|
+
onChange: (html: string) => void;
|
|
17
|
+
/** Uploads an image to the item and resolves with a URL that shows it; absent until the item exists. */
|
|
18
|
+
uploadImage?: (file: File) => Promise<string>;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
"aria-label"?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ContentManagerProps extends AdminFlowProps, AdminRouteProps {
|
|
24
|
+
/** The content kind managed. */
|
|
25
|
+
kind: string;
|
|
26
|
+
/** Languages to write in: codes, or codes with labels; the first is a new item's. */
|
|
27
|
+
languages?: readonly Choice[];
|
|
28
|
+
/**
|
|
29
|
+
* The body editor: `richTextEditor` from `@openrails/contentkit-ui/editor`,
|
|
30
|
+
* or the host's own. Without it, the body is a plain HTML field.
|
|
31
|
+
*/
|
|
32
|
+
renderEditor?: (props: BodyEditorProps) => ReactNode;
|
|
33
|
+
/** A link to a live item's page. */
|
|
34
|
+
contentHref?: (content: Content) => string | undefined;
|
|
35
|
+
/** Display names of kinds, traits, tiers, attributes and values by identifier. */
|
|
36
|
+
labels?: Labels;
|
|
37
|
+
pageSize?: number;
|
|
38
|
+
}
|
|
39
|
+
/** Whether the caller manages content: root:content:write holders, creators and owner-group editors. */
|
|
40
|
+
export declare function useContentManagerAccess(o?: FlowClientOptions): StaffAccess<"contents">;
|
|
41
|
+
export type ContentStatus = "draft" | "scheduled" | "published" | "held" | "rejected";
|
|
42
|
+
/** An item's status as the manager names it. */
|
|
43
|
+
export declare function contentStatus(c: Content): ContentStatus;
|
|
44
|
+
/**
|
|
45
|
+
* Content items of one kind for their creators and staff: every one the
|
|
46
|
+
* caller manages, by state and text, deleted ones on their own to restore;
|
|
47
|
+
* create and edit title, slug, description, schedule, cover and body with
|
|
48
|
+
* inline images per language, publish or keep a draft, and delete; then its
|
|
49
|
+
* listing and attributes, access rule and price, versions (order, languages,
|
|
50
|
+
* traits, schedule, access override, price, segments, media) and groups. The
|
|
51
|
+
* list is at basePath, a new item at basePath/new and each item at
|
|
52
|
+
* basePath/{id}, filters in the query.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ContentManager({ client: own, baseUrl, auth, guard, appearance, className, language, messages, ...p }: ContentManagerProps): import('react').JSX.Element;
|
|
55
|
+
export interface ContentEditorProps {
|
|
56
|
+
/** The item edited; null creates one of kind. */
|
|
57
|
+
id: string | null;
|
|
58
|
+
kind: string;
|
|
59
|
+
/** Languages to write in: codes, or codes with labels; the first is a new item's. */
|
|
60
|
+
languages?: readonly Choice[];
|
|
61
|
+
/** The body editor; without it, a plain HTML field. */
|
|
62
|
+
renderEditor?: (props: BodyEditorProps) => ReactNode;
|
|
63
|
+
/** A link to a live item's page. */
|
|
64
|
+
contentHref?: (content: Content) => string | undefined;
|
|
65
|
+
labels?: Labels;
|
|
66
|
+
/** A new item's owner group: a channel its editors write for. */
|
|
67
|
+
ownerGroup?: string;
|
|
68
|
+
/** After create: show the new item (the editor goes on editing it). */
|
|
69
|
+
onCreated?: (content: Content) => void;
|
|
70
|
+
onDeleted?: (content: Content) => void;
|
|
71
|
+
client?: ContentKitClient;
|
|
72
|
+
onError?: ContentKitErrorHandler;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One content item for its creators and staff: title, slug, description,
|
|
76
|
+
* schedule, cover and body per language, publish, unpublish and delete;
|
|
77
|
+
* then listing and attributes, access rule and price, versions and groups.
|
|
78
|
+
*/
|
|
79
|
+
export declare function ContentEditor({ id, client: own, kind, languages: offered, renderEditor, contentHref, labels, ownerGroup, onCreated, onDeleted, onError }: ContentEditorProps): import('react').JSX.Element;
|
|
80
|
+
export {};
|