@anvilkit/plugin-asset-manager 0.1.5 → 0.1.7
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 +27 -19
- package/dist/adapters/data-url.cjs +9 -5
- package/dist/adapters/extract-image-dimensions.cjs +12 -8
- package/dist/adapters/in-memory.cjs +9 -5
- package/dist/adapters/s3-presigned.cjs +9 -5
- package/dist/index.cjs +16 -5
- package/dist/index.d.cts +11 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/plugin.cjs +76 -9
- package/dist/plugin.d.cts +3 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +3 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +67 -4
- package/dist/sources/composite-source.cjs +137 -0
- package/dist/sources/composite-source.d.cts +39 -0
- package/dist/sources/composite-source.d.cts.map +1 -0
- package/dist/sources/composite-source.d.ts +39 -0
- package/dist/sources/composite-source.d.ts.map +1 -0
- package/dist/sources/composite-source.js +99 -0
- package/dist/sources/federated-search.cjs +163 -0
- package/dist/sources/federated-search.d.cts +33 -0
- package/dist/sources/federated-search.d.cts.map +1 -0
- package/dist/sources/federated-search.d.ts +33 -0
- package/dist/sources/federated-search.d.ts.map +1 -0
- package/dist/sources/federated-search.js +113 -0
- package/dist/sources/provider.cjs +18 -0
- package/dist/sources/provider.d.cts +51 -0
- package/dist/sources/provider.d.cts.map +1 -0
- package/dist/sources/provider.d.ts +51 -0
- package/dist/sources/provider.d.ts.map +1 -0
- package/dist/sources/provider.js +1 -0
- package/dist/sources/unsplash/client.cjs +189 -0
- package/dist/sources/unsplash/client.d.cts +87 -0
- package/dist/sources/unsplash/client.d.cts.map +1 -0
- package/dist/sources/unsplash/client.d.ts +87 -0
- package/dist/sources/unsplash/client.d.ts.map +1 -0
- package/dist/sources/unsplash/client.js +151 -0
- package/dist/sources/unsplash/index.cjs +192 -0
- package/dist/sources/unsplash/index.d.cts +16 -0
- package/dist/sources/unsplash/index.d.cts.map +1 -0
- package/dist/sources/unsplash/index.d.ts +16 -0
- package/dist/sources/unsplash/index.d.ts.map +1 -0
- package/dist/sources/unsplash/index.js +148 -0
- package/dist/sources/unsplash/themes.cjs +141 -0
- package/dist/sources/unsplash/themes.d.cts +18 -0
- package/dist/sources/unsplash/themes.d.cts.map +1 -0
- package/dist/sources/unsplash/themes.d.ts +18 -0
- package/dist/sources/unsplash/themes.d.ts.map +1 -0
- package/dist/sources/unsplash/themes.js +93 -0
- package/dist/sources/unsplash/throttle-cache.cjs +86 -0
- package/dist/sources/unsplash/throttle-cache.d.cts +25 -0
- package/dist/sources/unsplash/throttle-cache.d.cts.map +1 -0
- package/dist/sources/unsplash/throttle-cache.d.ts +25 -0
- package/dist/sources/unsplash/throttle-cache.d.ts.map +1 -0
- package/dist/sources/unsplash/throttle-cache.js +45 -0
- package/dist/testing/index.cjs +9 -5
- package/dist/types/categories.cjs +18 -0
- package/dist/types/categories.d.cts +48 -0
- package/dist/types/categories.d.cts.map +1 -0
- package/dist/types/categories.d.ts +48 -0
- package/dist/types/categories.d.ts.map +1 -0
- package/dist/types/categories.js +1 -0
- package/dist/types/data-source.cjs +18 -0
- package/dist/types/data-source.d.cts +59 -0
- package/dist/types/data-source.d.cts.map +1 -0
- package/dist/types/data-source.d.ts +59 -0
- package/dist/types/data-source.d.ts.map +1 -0
- package/dist/types/data-source.js +1 -0
- package/dist/types/filter.cjs +18 -0
- package/dist/types/filter.d.cts +55 -0
- package/dist/types/filter.d.cts.map +1 -0
- package/dist/types/filter.d.ts +55 -0
- package/dist/types/filter.d.ts.map +1 -0
- package/dist/types/filter.js +1 -0
- package/dist/types/folders.cjs +42 -0
- package/dist/types/folders.d.cts +46 -0
- package/dist/types/folders.d.cts.map +1 -0
- package/dist/types/folders.d.ts +46 -0
- package/dist/types/folders.d.ts.map +1 -0
- package/dist/types/folders.js +4 -0
- package/dist/types/options.cjs +18 -0
- package/dist/types/options.d.cts +68 -0
- package/dist/types/options.d.cts.map +1 -0
- package/dist/types/options.d.ts +68 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +1 -0
- package/dist/types/types.d.cts +15 -27
- package/dist/types/types.d.cts.map +1 -1
- package/dist/types/types.d.ts +15 -27
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/unsplash.cjs +18 -0
- package/dist/types/unsplash.d.cts +60 -0
- package/dist/types/unsplash.d.cts.map +1 -0
- package/dist/types/unsplash.d.ts +60 -0
- package/dist/types/unsplash.d.ts.map +1 -0
- package/dist/types/unsplash.js +1 -0
- package/dist/ui/AssetBrowser.cjs +69 -104
- package/dist/ui/AssetBrowser.d.cts +17 -7
- package/dist/ui/AssetBrowser.d.cts.map +1 -1
- package/dist/ui/AssetBrowser.d.ts +17 -7
- package/dist/ui/AssetBrowser.d.ts.map +1 -1
- package/dist/ui/AssetBrowser.js +60 -99
- package/dist/ui/AssetCommandPalette.cjs +9 -5
- package/dist/ui/AssetManagerUI.cjs +17 -7
- package/dist/ui/AssetManagerUI.d.cts +19 -3
- package/dist/ui/AssetManagerUI.d.cts.map +1 -1
- package/dist/ui/AssetManagerUI.d.ts +19 -3
- package/dist/ui/AssetManagerUI.d.ts.map +1 -1
- package/dist/ui/AssetManagerUI.js +8 -2
- package/dist/ui/DeleteAssetDialog.cjs +9 -5
- package/dist/ui/DeleteFolderDialog.cjs +78 -0
- package/dist/ui/DeleteFolderDialog.d.cts +11 -0
- package/dist/ui/DeleteFolderDialog.d.cts.map +1 -0
- package/dist/ui/DeleteFolderDialog.d.ts +11 -0
- package/dist/ui/DeleteFolderDialog.d.ts.map +1 -0
- package/dist/ui/DeleteFolderDialog.js +40 -0
- package/dist/ui/EmptyFolderState.cjs +53 -0
- package/dist/ui/EmptyFolderState.d.cts +6 -0
- package/dist/ui/EmptyFolderState.d.cts.map +1 -0
- package/dist/ui/EmptyFolderState.d.ts +6 -0
- package/dist/ui/EmptyFolderState.d.ts.map +1 -0
- package/dist/ui/EmptyFolderState.js +15 -0
- package/dist/ui/FolderBreadcrumb.cjs +73 -0
- package/dist/ui/FolderBreadcrumb.d.cts +9 -0
- package/dist/ui/FolderBreadcrumb.d.cts.map +1 -0
- package/dist/ui/FolderBreadcrumb.d.ts +9 -0
- package/dist/ui/FolderBreadcrumb.d.ts.map +1 -0
- package/dist/ui/FolderBreadcrumb.js +35 -0
- package/dist/ui/FolderNameDialog.cjs +98 -0
- package/dist/ui/FolderNameDialog.d.cts +14 -0
- package/dist/ui/FolderNameDialog.d.cts.map +1 -0
- package/dist/ui/FolderNameDialog.d.ts +14 -0
- package/dist/ui/FolderNameDialog.d.ts.map +1 -0
- package/dist/ui/FolderNameDialog.js +60 -0
- package/dist/ui/FolderTree.cjs +83 -0
- package/dist/ui/FolderTree.d.cts +13 -0
- package/dist/ui/FolderTree.d.cts.map +1 -0
- package/dist/ui/FolderTree.d.ts +13 -0
- package/dist/ui/FolderTree.d.ts.map +1 -0
- package/dist/ui/FolderTree.js +42 -0
- package/dist/ui/MetadataPanel.cjs +16 -9
- package/dist/ui/MetadataPanel.d.cts.map +1 -1
- package/dist/ui/MetadataPanel.d.ts.map +1 -1
- package/dist/ui/MetadataPanel.js +7 -4
- package/dist/ui/MoveTargetPicker.cjs +84 -0
- package/dist/ui/MoveTargetPicker.d.cts +16 -0
- package/dist/ui/MoveTargetPicker.d.cts.map +1 -0
- package/dist/ui/MoveTargetPicker.d.ts +16 -0
- package/dist/ui/MoveTargetPicker.d.ts.map +1 -0
- package/dist/ui/MoveTargetPicker.js +46 -0
- package/dist/ui/ReplaceAssetDialog.cjs +9 -5
- package/dist/ui/ReplaceAssetDialog.d.cts +2 -1
- package/dist/ui/ReplaceAssetDialog.d.cts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.d.ts +2 -1
- package/dist/ui/ReplaceAssetDialog.d.ts.map +1 -1
- package/dist/ui/UnsplashPanel.cjs +134 -0
- package/dist/ui/UnsplashPanel.d.cts +28 -0
- package/dist/ui/UnsplashPanel.d.cts.map +1 -0
- package/dist/ui/UnsplashPanel.d.ts +28 -0
- package/dist/ui/UnsplashPanel.d.ts.map +1 -0
- package/dist/ui/UnsplashPanel.js +96 -0
- package/dist/ui/UploadButton.cjs +10 -10
- package/dist/ui/UploadButton.d.cts +9 -2
- package/dist/ui/UploadButton.d.cts.map +1 -1
- package/dist/ui/UploadButton.d.ts +9 -2
- package/dist/ui/UploadButton.d.ts.map +1 -1
- package/dist/ui/UploadButton.js +1 -5
- package/dist/ui/index.cjs +46 -5
- package/dist/ui/index.d.cts +14 -0
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.ts +14 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +7 -0
- package/dist/utils/asset-reference.cjs +12 -8
- package/dist/utils/csp.cjs +12 -8
- package/dist/utils/data-source.cjs +177 -0
- package/dist/utils/data-source.d.cts +63 -0
- package/dist/utils/data-source.d.cts.map +1 -0
- package/dist/utils/data-source.d.ts +63 -0
- package/dist/utils/data-source.d.ts.map +1 -0
- package/dist/utils/data-source.js +136 -0
- package/dist/utils/errors.cjs +31 -9
- package/dist/utils/errors.d.cts +27 -0
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.ts +27 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +16 -1
- package/dist/utils/folders.cjs +261 -0
- package/dist/utils/folders.d.cts +49 -0
- package/dist/utils/folders.d.cts.map +1 -0
- package/dist/utils/folders.d.ts +49 -0
- package/dist/utils/folders.d.ts.map +1 -0
- package/dist/utils/folders.js +223 -0
- package/dist/utils/header-action.cjs +12 -8
- package/dist/utils/infer-kind.cjs +12 -8
- package/dist/utils/registry.cjs +36 -17
- package/dist/utils/registry.d.cts +21 -1
- package/dist/utils/registry.d.cts.map +1 -1
- package/dist/utils/registry.d.ts +21 -1
- package/dist/utils/registry.d.ts.map +1 -1
- package/dist/utils/registry.js +20 -11
- package/dist/utils/resolver.cjs +9 -5
- package/dist/utils/retry.cjs +13 -9
- package/dist/utils/studio-asset-source.cjs +14 -7
- package/dist/utils/studio-asset-source.d.cts +6 -1
- package/dist/utils/studio-asset-source.d.cts.map +1 -1
- package/dist/utils/studio-asset-source.d.ts +6 -1
- package/dist/utils/studio-asset-source.d.ts.map +1 -1
- package/dist/utils/studio-asset-source.js +1 -1
- package/dist/utils/validate-upload-result.cjs +9 -5
- package/dist/utils/validate-upload-result.d.cts +2 -1
- package/dist/utils/validate-upload-result.d.cts.map +1 -1
- package/dist/utils/validate-upload-result.d.ts +2 -1
- package/dist/utils/validate-upload-result.d.ts.map +1 -1
- package/dist/version.cjs +12 -8
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/meta/config.json +1 -1
- package/package.json +19 -9
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Default Unsplash theme set + resolution (PRD 0002 §8.2). A theme maps
|
|
3
|
+
* to an Unsplash topic slug (tried first), a curated search query (fallback /
|
|
4
|
+
* supplement), or both. Labels are i18n message keys, never inline copy.
|
|
5
|
+
*/
|
|
6
|
+
import type { UnsplashTheme, UnsplashThemeConfig } from "../../types/unsplash.js";
|
|
7
|
+
/** The free-search pseudo-theme prepended unless `allowFreeSearch === false`. */
|
|
8
|
+
export declare const ALL_THEME_ID = "__all__";
|
|
9
|
+
export declare const DEFAULT_UNSPLASH_THEMES: readonly UnsplashTheme[];
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the effective theme list: replace-all when `themes` is given, else
|
|
12
|
+
* filter the defaults by `excludeThemes` and append `additionalThemes`. The
|
|
13
|
+
* `__all__` free-search pseudo-theme is prepended unless disabled.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveThemes(config?: UnsplashThemeConfig): readonly UnsplashTheme[];
|
|
16
|
+
/** Pick the initial theme: the configured default if present, else the first. */
|
|
17
|
+
export declare function resolveDefaultThemeId(themes: readonly UnsplashTheme[], config?: UnsplashThemeConfig): string | undefined;
|
|
18
|
+
//# sourceMappingURL=themes.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.cts","sourceRoot":"","sources":["../../../src/sources/unsplash/themes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,iFAAiF;AACjF,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,uBAAuB,EAAE,SAAS,aAAa,EAmD1D,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,MAAM,CAAC,EAAE,mBAAmB,GAC1B,SAAS,aAAa,EAAE,CAqB1B;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,MAAM,CAAC,EAAE,mBAAmB,GAC1B,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Default Unsplash theme set + resolution (PRD 0002 §8.2). A theme maps
|
|
3
|
+
* to an Unsplash topic slug (tried first), a curated search query (fallback /
|
|
4
|
+
* supplement), or both. Labels are i18n message keys, never inline copy.
|
|
5
|
+
*/
|
|
6
|
+
import type { UnsplashTheme, UnsplashThemeConfig } from "../../types/unsplash.js";
|
|
7
|
+
/** The free-search pseudo-theme prepended unless `allowFreeSearch === false`. */
|
|
8
|
+
export declare const ALL_THEME_ID = "__all__";
|
|
9
|
+
export declare const DEFAULT_UNSPLASH_THEMES: readonly UnsplashTheme[];
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the effective theme list: replace-all when `themes` is given, else
|
|
12
|
+
* filter the defaults by `excludeThemes` and append `additionalThemes`. The
|
|
13
|
+
* `__all__` free-search pseudo-theme is prepended unless disabled.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveThemes(config?: UnsplashThemeConfig): readonly UnsplashTheme[];
|
|
16
|
+
/** Pick the initial theme: the configured default if present, else the first. */
|
|
17
|
+
export declare function resolveDefaultThemeId(themes: readonly UnsplashTheme[], config?: UnsplashThemeConfig): string | undefined;
|
|
18
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../../src/sources/unsplash/themes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,iFAAiF;AACjF,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,uBAAuB,EAAE,SAAS,aAAa,EAmD1D,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,MAAM,CAAC,EAAE,mBAAmB,GAC1B,SAAS,aAAa,EAAE,CAqB1B;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,SAAS,aAAa,EAAE,EAChC,MAAM,CAAC,EAAE,mBAAmB,GAC1B,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const ALL_THEME_ID = "__all__";
|
|
2
|
+
const DEFAULT_UNSPLASH_THEMES = Object.freeze([
|
|
3
|
+
{
|
|
4
|
+
id: "nature",
|
|
5
|
+
label: "assetManager.unsplash.theme.nature",
|
|
6
|
+
topicSlugs: [
|
|
7
|
+
"nature"
|
|
8
|
+
],
|
|
9
|
+
query: "nature landscape",
|
|
10
|
+
orientation: "landscape"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "architecture",
|
|
14
|
+
label: "assetManager.unsplash.theme.architecture",
|
|
15
|
+
topicSlugs: [
|
|
16
|
+
"architecture-interior"
|
|
17
|
+
],
|
|
18
|
+
query: "architecture building"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "business",
|
|
22
|
+
label: "assetManager.unsplash.theme.business",
|
|
23
|
+
topicSlugs: [
|
|
24
|
+
"business-work"
|
|
25
|
+
],
|
|
26
|
+
query: "business office work"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "food",
|
|
30
|
+
label: "assetManager.unsplash.theme.food",
|
|
31
|
+
topicSlugs: [
|
|
32
|
+
"food-drink"
|
|
33
|
+
],
|
|
34
|
+
query: "food meal"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "technology",
|
|
38
|
+
label: "assetManager.unsplash.theme.technology",
|
|
39
|
+
topicSlugs: [
|
|
40
|
+
"experimental"
|
|
41
|
+
],
|
|
42
|
+
query: "technology computer"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "travel",
|
|
46
|
+
label: "assetManager.unsplash.theme.travel",
|
|
47
|
+
topicSlugs: [
|
|
48
|
+
"travel"
|
|
49
|
+
],
|
|
50
|
+
query: "travel destination"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "texture",
|
|
54
|
+
label: "assetManager.unsplash.theme.texture",
|
|
55
|
+
topicSlugs: [
|
|
56
|
+
"textures-patterns"
|
|
57
|
+
],
|
|
58
|
+
query: "abstract texture",
|
|
59
|
+
orientation: "squarish"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "people",
|
|
63
|
+
label: "assetManager.unsplash.theme.people",
|
|
64
|
+
topicSlugs: [
|
|
65
|
+
"people"
|
|
66
|
+
],
|
|
67
|
+
query: "people portrait"
|
|
68
|
+
}
|
|
69
|
+
]);
|
|
70
|
+
function resolveThemes(config) {
|
|
71
|
+
let base;
|
|
72
|
+
if (config?.themes) base = config.themes;
|
|
73
|
+
else {
|
|
74
|
+
const excluded = new Set(config?.excludeThemes ?? []);
|
|
75
|
+
const filtered = excluded.size > 0 ? DEFAULT_UNSPLASH_THEMES.filter((t)=>!excluded.has(t.id)) : DEFAULT_UNSPLASH_THEMES;
|
|
76
|
+
base = config?.additionalThemes ? [
|
|
77
|
+
...filtered,
|
|
78
|
+
...config.additionalThemes
|
|
79
|
+
] : filtered;
|
|
80
|
+
}
|
|
81
|
+
const themes = [];
|
|
82
|
+
if (config?.allowFreeSearch !== false) themes.push({
|
|
83
|
+
id: ALL_THEME_ID,
|
|
84
|
+
label: "assetManager.unsplash.theme.all"
|
|
85
|
+
});
|
|
86
|
+
themes.push(...base);
|
|
87
|
+
return Object.freeze(themes);
|
|
88
|
+
}
|
|
89
|
+
function resolveDefaultThemeId(themes, config) {
|
|
90
|
+
if (config?.defaultThemeId && themes.some((t)=>t.id === config.defaultThemeId)) return config.defaultThemeId;
|
|
91
|
+
return themes[0]?.id;
|
|
92
|
+
}
|
|
93
|
+
export { ALL_THEME_ID, DEFAULT_UNSPLASH_THEMES, resolveDefaultThemeId, resolveThemes };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
function createTtlCache(ttlMs, maxEntries = 100) {
|
|
31
|
+
const map = new Map();
|
|
32
|
+
return {
|
|
33
|
+
get (key, now) {
|
|
34
|
+
const entry = map.get(key);
|
|
35
|
+
if (void 0 === entry) return;
|
|
36
|
+
if (entry.expires <= now) return void map.delete(key);
|
|
37
|
+
map.delete(key);
|
|
38
|
+
map.set(key, entry);
|
|
39
|
+
return entry.value;
|
|
40
|
+
},
|
|
41
|
+
set (key, value, now) {
|
|
42
|
+
if (!map.has(key) && map.size >= maxEntries) {
|
|
43
|
+
const oldest = map.keys().next().value;
|
|
44
|
+
if (void 0 !== oldest) map.delete(oldest);
|
|
45
|
+
}
|
|
46
|
+
map.set(key, {
|
|
47
|
+
value,
|
|
48
|
+
expires: now + ttlMs
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
get size () {
|
|
52
|
+
return map.size;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function createSingleFlightThrottle(options) {
|
|
57
|
+
const now = options.now ?? (()=>Date.now());
|
|
58
|
+
const wait = options.wait ?? ((ms)=>new Promise((resolve)=>setTimeout(resolve, ms)));
|
|
59
|
+
let last = -1 / 0;
|
|
60
|
+
let chain = Promise.resolve();
|
|
61
|
+
return {
|
|
62
|
+
run (task) {
|
|
63
|
+
const result = chain.then(async ()=>{
|
|
64
|
+
const elapsed = now() - last;
|
|
65
|
+
if (elapsed < options.minIntervalMs) await wait(options.minIntervalMs - elapsed);
|
|
66
|
+
last = now();
|
|
67
|
+
return task();
|
|
68
|
+
});
|
|
69
|
+
chain = result.then(()=>void 0, ()=>void 0);
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
75
|
+
createSingleFlightThrottle: ()=>createSingleFlightThrottle,
|
|
76
|
+
createTtlCache: ()=>createTtlCache
|
|
77
|
+
});
|
|
78
|
+
exports.createSingleFlightThrottle = __webpack_exports__.createSingleFlightThrottle;
|
|
79
|
+
exports.createTtlCache = __webpack_exports__.createTtlCache;
|
|
80
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
81
|
+
"createSingleFlightThrottle",
|
|
82
|
+
"createTtlCache"
|
|
83
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
84
|
+
Object.defineProperty(exports, '__esModule', {
|
|
85
|
+
value: true
|
|
86
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Rate-limit discipline for Unsplash JSON calls (PRD 0002 §8.5): an
|
|
3
|
+
* LRU+TTL result cache and a single-flight throttle that enforces a minimum
|
|
4
|
+
* interval between requests. Clock + wait are injectable for deterministic tests.
|
|
5
|
+
*/
|
|
6
|
+
export interface TtlCache<T> {
|
|
7
|
+
get(key: string, now: number): T | undefined;
|
|
8
|
+
set(key: string, value: T, now: number): void;
|
|
9
|
+
readonly size: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function createTtlCache<T>(ttlMs: number, maxEntries?: number): TtlCache<T>;
|
|
12
|
+
export interface SingleFlightThrottle {
|
|
13
|
+
run<T>(task: () => Promise<T>): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateThrottleOptions {
|
|
16
|
+
readonly minIntervalMs: number;
|
|
17
|
+
readonly now?: () => number;
|
|
18
|
+
readonly wait?: (ms: number) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Serializes tasks and guarantees at least `minIntervalMs` between the *starts*
|
|
22
|
+
* of consecutive tasks — the politeness Unsplash's quota requires.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSingleFlightThrottle(options: CreateThrottleOptions): SingleFlightThrottle;
|
|
25
|
+
//# sourceMappingURL=throttle-cache.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle-cache.d.cts","sourceRoot":"","sources":["../../../src/sources/unsplash/throttle-cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,EACb,UAAU,SAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CA0Bb;AAED,MAAM,WAAW,oBAAoB;IACpC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,qBAAqB,GAC5B,oBAAoB,CA0BtB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Rate-limit discipline for Unsplash JSON calls (PRD 0002 §8.5): an
|
|
3
|
+
* LRU+TTL result cache and a single-flight throttle that enforces a minimum
|
|
4
|
+
* interval between requests. Clock + wait are injectable for deterministic tests.
|
|
5
|
+
*/
|
|
6
|
+
export interface TtlCache<T> {
|
|
7
|
+
get(key: string, now: number): T | undefined;
|
|
8
|
+
set(key: string, value: T, now: number): void;
|
|
9
|
+
readonly size: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function createTtlCache<T>(ttlMs: number, maxEntries?: number): TtlCache<T>;
|
|
12
|
+
export interface SingleFlightThrottle {
|
|
13
|
+
run<T>(task: () => Promise<T>): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateThrottleOptions {
|
|
16
|
+
readonly minIntervalMs: number;
|
|
17
|
+
readonly now?: () => number;
|
|
18
|
+
readonly wait?: (ms: number) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Serializes tasks and guarantees at least `minIntervalMs` between the *starts*
|
|
22
|
+
* of consecutive tasks — the politeness Unsplash's quota requires.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSingleFlightThrottle(options: CreateThrottleOptions): SingleFlightThrottle;
|
|
25
|
+
//# sourceMappingURL=throttle-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle-cache.d.ts","sourceRoot":"","sources":["../../../src/sources/unsplash/throttle-cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,EACb,UAAU,SAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CA0Bb;AAED,MAAM,WAAW,oBAAoB;IACpC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,qBAAqB,GAC5B,oBAAoB,CA0BtB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function createTtlCache(ttlMs, maxEntries = 100) {
|
|
2
|
+
const map = new Map();
|
|
3
|
+
return {
|
|
4
|
+
get (key, now) {
|
|
5
|
+
const entry = map.get(key);
|
|
6
|
+
if (void 0 === entry) return;
|
|
7
|
+
if (entry.expires <= now) return void map.delete(key);
|
|
8
|
+
map.delete(key);
|
|
9
|
+
map.set(key, entry);
|
|
10
|
+
return entry.value;
|
|
11
|
+
},
|
|
12
|
+
set (key, value, now) {
|
|
13
|
+
if (!map.has(key) && map.size >= maxEntries) {
|
|
14
|
+
const oldest = map.keys().next().value;
|
|
15
|
+
if (void 0 !== oldest) map.delete(oldest);
|
|
16
|
+
}
|
|
17
|
+
map.set(key, {
|
|
18
|
+
value,
|
|
19
|
+
expires: now + ttlMs
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
get size () {
|
|
23
|
+
return map.size;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function createSingleFlightThrottle(options) {
|
|
28
|
+
const now = options.now ?? (()=>Date.now());
|
|
29
|
+
const wait = options.wait ?? ((ms)=>new Promise((resolve)=>setTimeout(resolve, ms)));
|
|
30
|
+
let last = -1 / 0;
|
|
31
|
+
let chain = Promise.resolve();
|
|
32
|
+
return {
|
|
33
|
+
run (task) {
|
|
34
|
+
const result = chain.then(async ()=>{
|
|
35
|
+
const elapsed = now() - last;
|
|
36
|
+
if (elapsed < options.minIntervalMs) await wait(options.minIntervalMs - elapsed);
|
|
37
|
+
last = now();
|
|
38
|
+
return task();
|
|
39
|
+
});
|
|
40
|
+
chain = result.then(()=>void 0, ()=>void 0);
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export { createSingleFlightThrottle, createTtlCache };
|
package/dist/testing/index.cjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Extensible categorization / facet registry (PRD 0002 §3.5, §9.2).
|
|
3
|
+
*
|
|
4
|
+
* `kind`, `tags`, `folder`, and `source` are built-in facets registered by the
|
|
5
|
+
* plugin; hosts append {@link AssetFacetDefinition}s rather than reconfigure.
|
|
6
|
+
* {@link AssetCategory} is a host-friendly "saved view" sugar over filters and
|
|
7
|
+
* providers, surfaced as chips beside the kind chips.
|
|
8
|
+
*/
|
|
9
|
+
import type { AssetSourceId } from "./filter.js";
|
|
10
|
+
import type { AssetKind, UploadResult } from "./types.js";
|
|
11
|
+
export interface AssetFacetOption {
|
|
12
|
+
readonly value: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** Populated by memoized facet counts when available. */
|
|
15
|
+
readonly count?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface AssetFacetDefinition {
|
|
18
|
+
/** Stable key; used in `AssetFilter.facets[id]`. */
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly label: string;
|
|
21
|
+
/** `"single"` renders as chips/radio; `"multi"` as a multiselect. */
|
|
22
|
+
readonly selection: "single" | "multi";
|
|
23
|
+
/** Which sources this facet applies to. `undefined` ⇒ all. */
|
|
24
|
+
readonly appliesTo?: readonly AssetSourceId[];
|
|
25
|
+
/** Derive the asset's value(s) for this facet (local, sync). */
|
|
26
|
+
readonly valueOf?: (asset: UploadResult) => readonly string[] | undefined;
|
|
27
|
+
/** Static options, or an async loader for remote facets (e.g. Unsplash topics). */
|
|
28
|
+
readonly options?: readonly AssetFacetOption[] | ((ctx: {
|
|
29
|
+
readonly source?: AssetSourceId;
|
|
30
|
+
}) => Promise<readonly AssetFacetOption[]>);
|
|
31
|
+
/** When true, the facet is delegated to the source instead of matched locally. */
|
|
32
|
+
readonly remote?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface AssetCategory {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly label: string;
|
|
37
|
+
/** Local match composed with AND-semantic search. */
|
|
38
|
+
readonly match?: {
|
|
39
|
+
readonly tags?: readonly string[];
|
|
40
|
+
readonly kinds?: readonly AssetKind[];
|
|
41
|
+
};
|
|
42
|
+
/** Route the category to an external provider/theme instead of a local match. */
|
|
43
|
+
readonly provider?: {
|
|
44
|
+
readonly source: AssetSourceId;
|
|
45
|
+
readonly theme?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=categories.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.d.cts","sourceRoot":"","sources":["../../src/types/categories.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACpC,oDAAoD;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1E,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EACd,SAAS,gBAAgB,EAAE,GAC3B,CAAC,CAAC,GAAG,EAAE;QACP,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;KAC/B,KAAK,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAAC,CAAC;IAC/C,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,KAAK,CAAC,EAAE;QAChB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;KACtC,CAAC;IACF,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACnB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;QAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Extensible categorization / facet registry (PRD 0002 §3.5, §9.2).
|
|
3
|
+
*
|
|
4
|
+
* `kind`, `tags`, `folder`, and `source` are built-in facets registered by the
|
|
5
|
+
* plugin; hosts append {@link AssetFacetDefinition}s rather than reconfigure.
|
|
6
|
+
* {@link AssetCategory} is a host-friendly "saved view" sugar over filters and
|
|
7
|
+
* providers, surfaced as chips beside the kind chips.
|
|
8
|
+
*/
|
|
9
|
+
import type { AssetSourceId } from "./filter.js";
|
|
10
|
+
import type { AssetKind, UploadResult } from "./types.js";
|
|
11
|
+
export interface AssetFacetOption {
|
|
12
|
+
readonly value: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** Populated by memoized facet counts when available. */
|
|
15
|
+
readonly count?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface AssetFacetDefinition {
|
|
18
|
+
/** Stable key; used in `AssetFilter.facets[id]`. */
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly label: string;
|
|
21
|
+
/** `"single"` renders as chips/radio; `"multi"` as a multiselect. */
|
|
22
|
+
readonly selection: "single" | "multi";
|
|
23
|
+
/** Which sources this facet applies to. `undefined` ⇒ all. */
|
|
24
|
+
readonly appliesTo?: readonly AssetSourceId[];
|
|
25
|
+
/** Derive the asset's value(s) for this facet (local, sync). */
|
|
26
|
+
readonly valueOf?: (asset: UploadResult) => readonly string[] | undefined;
|
|
27
|
+
/** Static options, or an async loader for remote facets (e.g. Unsplash topics). */
|
|
28
|
+
readonly options?: readonly AssetFacetOption[] | ((ctx: {
|
|
29
|
+
readonly source?: AssetSourceId;
|
|
30
|
+
}) => Promise<readonly AssetFacetOption[]>);
|
|
31
|
+
/** When true, the facet is delegated to the source instead of matched locally. */
|
|
32
|
+
readonly remote?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface AssetCategory {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
readonly label: string;
|
|
37
|
+
/** Local match composed with AND-semantic search. */
|
|
38
|
+
readonly match?: {
|
|
39
|
+
readonly tags?: readonly string[];
|
|
40
|
+
readonly kinds?: readonly AssetKind[];
|
|
41
|
+
};
|
|
42
|
+
/** Route the category to an external provider/theme instead of a local match. */
|
|
43
|
+
readonly provider?: {
|
|
44
|
+
readonly source: AssetSourceId;
|
|
45
|
+
readonly theme?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=categories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../src/types/categories.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,E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,SAAS,EAAE,CAAC;KACtC,CAAC;IACF,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACnB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;QAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The unified host-facing data plane (PRD 0002 §3.3, §3.6).
|
|
3
|
+
*
|
|
4
|
+
* `AssetDataSource` is the ONE optional object a host supplies to back the local
|
|
5
|
+
* library. Every method is optional and async-first; any method (resolved
|
|
6
|
+
* per-plane) the host omits is filled by the built-in in-memory default. Binary
|
|
7
|
+
* ingest is NOT here — it stays on the top-level `uploader` (`UploadAdapter`).
|
|
8
|
+
*
|
|
9
|
+
* The READ is unified: `list()` returns the folder's assets, its child folders,
|
|
10
|
+
* and its breadcrumb in one envelope — there is deliberately no `listFolders`.
|
|
11
|
+
* Folder *mutations* are a separate plane.
|
|
12
|
+
*/
|
|
13
|
+
import type { AssetSourceError } from "../utils/errors.js";
|
|
14
|
+
import type { AssetFilter, AssetListPage } from "./filter.js";
|
|
15
|
+
import type { AssetFolder, FolderId } from "./folders.js";
|
|
16
|
+
import type { UploadResult } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Replacement payload for {@link AssetDataSource.replace}. Kept `File`-only for
|
|
19
|
+
* parity with core's `StudioAssetSource.replace` boundary; programmatic
|
|
20
|
+
* `UploadResult` replacement stays on the registry.
|
|
21
|
+
*/
|
|
22
|
+
export type ReplacePayload = File;
|
|
23
|
+
/** Loading/mutation status surfaced through {@link AssetDataSource.subscribeStatus}. */
|
|
24
|
+
export type AssetSourceStatus = {
|
|
25
|
+
readonly phase: "idle";
|
|
26
|
+
} | {
|
|
27
|
+
readonly phase: "loading";
|
|
28
|
+
} | {
|
|
29
|
+
readonly phase: "paginating";
|
|
30
|
+
readonly loaded: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly phase: "mutating";
|
|
33
|
+
readonly op: "rename" | "remove" | "move" | "replace" | "createFolder" | "removeFolder" | "moveFolder";
|
|
34
|
+
readonly id: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly phase: "error";
|
|
37
|
+
readonly error: AssetSourceError;
|
|
38
|
+
};
|
|
39
|
+
export interface AssetDataSource {
|
|
40
|
+
/**
|
|
41
|
+
* THE single read. Scoped by `query.folderId` (null=root, undefined=all),
|
|
42
|
+
* returns the folder's assets (paginated `items`), its child `folders`, and
|
|
43
|
+
* its `folderPath` breadcrumb in one envelope. No separate `listFolders`.
|
|
44
|
+
*/
|
|
45
|
+
list?(query: AssetFilter, signal?: AbortSignal): Promise<AssetListPage>;
|
|
46
|
+
remove?(id: string, signal?: AbortSignal): Promise<void>;
|
|
47
|
+
replace?(id: string, payload: ReplacePayload, signal?: AbortSignal): Promise<UploadResult>;
|
|
48
|
+
rename?(id: string, name: string, signal?: AbortSignal): Promise<UploadResult>;
|
|
49
|
+
/** Move an asset into a folder. `null` ⇒ root. */
|
|
50
|
+
move?(id: string, folderId: FolderId | null, signal?: AbortSignal): Promise<void>;
|
|
51
|
+
createFolder?(parentId: FolderId | null, name: string, signal?: AbortSignal): Promise<AssetFolder>;
|
|
52
|
+
renameFolder?(id: FolderId, name: string, signal?: AbortSignal): Promise<AssetFolder>;
|
|
53
|
+
removeFolder?(id: FolderId, opts?: {
|
|
54
|
+
readonly cascade?: boolean;
|
|
55
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
56
|
+
moveFolder?(id: FolderId, parentId: FolderId | null, signal?: AbortSignal): Promise<AssetFolder>;
|
|
57
|
+
subscribeStatus?(listener: (status: AssetSourceStatus) => void): () => void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=data-source.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-source.d.cts","sourceRoot":"","sources":["../../src/types/data-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC;AAElC,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAC1B;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzD;IACA,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,EAAE,EACR,QAA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,EACZ,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,EACrC,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,UAAU,CAAC,CACV,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC,CAAC;IAGxB,eAAe,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAC5E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The unified host-facing data plane (PRD 0002 §3.3, §3.6).
|
|
3
|
+
*
|
|
4
|
+
* `AssetDataSource` is the ONE optional object a host supplies to back the local
|
|
5
|
+
* library. Every method is optional and async-first; any method (resolved
|
|
6
|
+
* per-plane) the host omits is filled by the built-in in-memory default. Binary
|
|
7
|
+
* ingest is NOT here — it stays on the top-level `uploader` (`UploadAdapter`).
|
|
8
|
+
*
|
|
9
|
+
* The READ is unified: `list()` returns the folder's assets, its child folders,
|
|
10
|
+
* and its breadcrumb in one envelope — there is deliberately no `listFolders`.
|
|
11
|
+
* Folder *mutations* are a separate plane.
|
|
12
|
+
*/
|
|
13
|
+
import type { AssetSourceError } from "../utils/errors.js";
|
|
14
|
+
import type { AssetFilter, AssetListPage } from "./filter.js";
|
|
15
|
+
import type { AssetFolder, FolderId } from "./folders.js";
|
|
16
|
+
import type { UploadResult } from "./types.js";
|
|
17
|
+
/**
|
|
18
|
+
* Replacement payload for {@link AssetDataSource.replace}. Kept `File`-only for
|
|
19
|
+
* parity with core's `StudioAssetSource.replace` boundary; programmatic
|
|
20
|
+
* `UploadResult` replacement stays on the registry.
|
|
21
|
+
*/
|
|
22
|
+
export type ReplacePayload = File;
|
|
23
|
+
/** Loading/mutation status surfaced through {@link AssetDataSource.subscribeStatus}. */
|
|
24
|
+
export type AssetSourceStatus = {
|
|
25
|
+
readonly phase: "idle";
|
|
26
|
+
} | {
|
|
27
|
+
readonly phase: "loading";
|
|
28
|
+
} | {
|
|
29
|
+
readonly phase: "paginating";
|
|
30
|
+
readonly loaded: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly phase: "mutating";
|
|
33
|
+
readonly op: "rename" | "remove" | "move" | "replace" | "createFolder" | "removeFolder" | "moveFolder";
|
|
34
|
+
readonly id: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly phase: "error";
|
|
37
|
+
readonly error: AssetSourceError;
|
|
38
|
+
};
|
|
39
|
+
export interface AssetDataSource {
|
|
40
|
+
/**
|
|
41
|
+
* THE single read. Scoped by `query.folderId` (null=root, undefined=all),
|
|
42
|
+
* returns the folder's assets (paginated `items`), its child `folders`, and
|
|
43
|
+
* its `folderPath` breadcrumb in one envelope. No separate `listFolders`.
|
|
44
|
+
*/
|
|
45
|
+
list?(query: AssetFilter, signal?: AbortSignal): Promise<AssetListPage>;
|
|
46
|
+
remove?(id: string, signal?: AbortSignal): Promise<void>;
|
|
47
|
+
replace?(id: string, payload: ReplacePayload, signal?: AbortSignal): Promise<UploadResult>;
|
|
48
|
+
rename?(id: string, name: string, signal?: AbortSignal): Promise<UploadResult>;
|
|
49
|
+
/** Move an asset into a folder. `null` ⇒ root. */
|
|
50
|
+
move?(id: string, folderId: FolderId | null, signal?: AbortSignal): Promise<void>;
|
|
51
|
+
createFolder?(parentId: FolderId | null, name: string, signal?: AbortSignal): Promise<AssetFolder>;
|
|
52
|
+
renameFolder?(id: FolderId, name: string, signal?: AbortSignal): Promise<AssetFolder>;
|
|
53
|
+
removeFolder?(id: FolderId, opts?: {
|
|
54
|
+
readonly cascade?: boolean;
|
|
55
|
+
}, signal?: AbortSignal): Promise<void>;
|
|
56
|
+
moveFolder?(id: FolderId, parentId: FolderId | null, signal?: AbortSignal): Promise<AssetFolder>;
|
|
57
|
+
subscribeStatus?(listener: (status: AssetSourceStatus) => void): () => void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=data-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../src/types/data-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC;AAElC,wFAAwF;AACxF,MAAM,MAAM,iBAAiB,GAC1B;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC1B;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzD;IACA,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,EAAE,EACR,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,SAAS,GACT,cAAc,GACd,cAAc,GACd,YAAY,CAAC;IAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACnB,GACD;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEjE,MAAM,WAAW,eAAe;IAE/B;;;;OAIG;IACH,IAAI,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,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