@happyvertical/smrt-assets 0.30.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.
Files changed (119) hide show
  1. package/AGENTS.md +78 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +136 -0
  5. package/dist/__smrt-register__.d.ts +2 -0
  6. package/dist/__smrt-register__.d.ts.map +1 -0
  7. package/dist/asset-association.d.ts +16 -0
  8. package/dist/asset-association.d.ts.map +1 -0
  9. package/dist/asset-associations.d.ts +27 -0
  10. package/dist/asset-associations.d.ts.map +1 -0
  11. package/dist/asset-capabilities.d.ts +137 -0
  12. package/dist/asset-capabilities.d.ts.map +1 -0
  13. package/dist/asset-conventions.d.ts +76 -0
  14. package/dist/asset-conventions.d.ts.map +1 -0
  15. package/dist/asset-metafield.d.ts +27 -0
  16. package/dist/asset-metafield.d.ts.map +1 -0
  17. package/dist/asset-metafields.d.ts +27 -0
  18. package/dist/asset-metafields.d.ts.map +1 -0
  19. package/dist/asset-runtime.d.ts +218 -0
  20. package/dist/asset-runtime.d.ts.map +1 -0
  21. package/dist/asset-serving.d.ts +146 -0
  22. package/dist/asset-serving.d.ts.map +1 -0
  23. package/dist/asset-status.d.ts +15 -0
  24. package/dist/asset-status.d.ts.map +1 -0
  25. package/dist/asset-statuses.d.ts +25 -0
  26. package/dist/asset-statuses.d.ts.map +1 -0
  27. package/dist/asset-store.d.ts +200 -0
  28. package/dist/asset-store.d.ts.map +1 -0
  29. package/dist/asset-type.d.ts +15 -0
  30. package/dist/asset-type.d.ts.map +1 -0
  31. package/dist/asset-types.d.ts +28 -0
  32. package/dist/asset-types.d.ts.map +1 -0
  33. package/dist/asset.d.ts +158 -0
  34. package/dist/asset.d.ts.map +1 -0
  35. package/dist/assets.d.ts +125 -0
  36. package/dist/assets.d.ts.map +1 -0
  37. package/dist/folder.d.ts +16 -0
  38. package/dist/folder.d.ts.map +1 -0
  39. package/dist/folders.d.ts +45 -0
  40. package/dist/folders.d.ts.map +1 -0
  41. package/dist/index.d.ts +21 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +2285 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/manifest.json +4079 -0
  46. package/dist/media-bundle-persistence.d.ts +99 -0
  47. package/dist/media-bundle-persistence.d.ts.map +1 -0
  48. package/dist/owned-asset-helpers.d.ts +20 -0
  49. package/dist/owned-asset-helpers.d.ts.map +1 -0
  50. package/dist/playground.d.ts +2 -0
  51. package/dist/playground.d.ts.map +1 -0
  52. package/dist/playground.js +127 -0
  53. package/dist/playground.js.map +1 -0
  54. package/dist/smrt-knowledge.json +1922 -0
  55. package/dist/svelte/ActionBar.svelte +203 -0
  56. package/dist/svelte/ActionBar.svelte.d.ts +5 -0
  57. package/dist/svelte/ActionBar.svelte.d.ts.map +1 -0
  58. package/dist/svelte/AssetDetail.svelte +521 -0
  59. package/dist/svelte/AssetDetail.svelte.d.ts +35 -0
  60. package/dist/svelte/AssetDetail.svelte.d.ts.map +1 -0
  61. package/dist/svelte/AssetGrid.svelte +351 -0
  62. package/dist/svelte/AssetGrid.svelte.d.ts +5 -0
  63. package/dist/svelte/AssetGrid.svelte.d.ts.map +1 -0
  64. package/dist/svelte/AssetList.svelte +436 -0
  65. package/dist/svelte/AssetList.svelte.d.ts +5 -0
  66. package/dist/svelte/AssetList.svelte.d.ts.map +1 -0
  67. package/dist/svelte/AssetManager.svelte +381 -0
  68. package/dist/svelte/AssetManager.svelte.d.ts +5 -0
  69. package/dist/svelte/AssetManager.svelte.d.ts.map +1 -0
  70. package/dist/svelte/AssetToolbar.svelte +388 -0
  71. package/dist/svelte/AssetToolbar.svelte.d.ts +5 -0
  72. package/dist/svelte/AssetToolbar.svelte.d.ts.map +1 -0
  73. package/dist/svelte/CreateAssetModal.svelte +373 -0
  74. package/dist/svelte/CreateAssetModal.svelte.d.ts +19 -0
  75. package/dist/svelte/CreateAssetModal.svelte.d.ts.map +1 -0
  76. package/dist/svelte/__tests__/ActionBar.test.js +72 -0
  77. package/dist/svelte/__tests__/AssetDetail.test.js +57 -0
  78. package/dist/svelte/__tests__/AssetGrid.test.js +69 -0
  79. package/dist/svelte/__tests__/AssetList.test.js +72 -0
  80. package/dist/svelte/__tests__/AssetManager.test.js +21 -0
  81. package/dist/svelte/__tests__/AssetManagerRoute.test.js +16 -0
  82. package/dist/svelte/__tests__/AssetToolbar.test.js +39 -0
  83. package/dist/svelte/__tests__/CreateAssetModal.test.js +42 -0
  84. package/dist/svelte/i18n.d.ts +76 -0
  85. package/dist/svelte/i18n.d.ts.map +1 -0
  86. package/dist/svelte/i18n.js +87 -0
  87. package/dist/svelte/index.d.ts +19 -0
  88. package/dist/svelte/index.d.ts.map +1 -0
  89. package/dist/svelte/index.js +30 -0
  90. package/dist/svelte/playground/AssetDetailPreview.svelte +131 -0
  91. package/dist/svelte/playground/AssetDetailPreview.svelte.d.ts +8 -0
  92. package/dist/svelte/playground/AssetDetailPreview.svelte.d.ts.map +1 -0
  93. package/dist/svelte/playground/CreateAssetModalPreview.svelte +151 -0
  94. package/dist/svelte/playground/CreateAssetModalPreview.svelte.d.ts +4 -0
  95. package/dist/svelte/playground/CreateAssetModalPreview.svelte.d.ts.map +1 -0
  96. package/dist/svelte/playground.d.ts +60 -0
  97. package/dist/svelte/playground.d.ts.map +1 -0
  98. package/dist/svelte/playground.js +93 -0
  99. package/dist/svelte/routes/AssetManagerRoute.svelte +209 -0
  100. package/dist/svelte/routes/AssetManagerRoute.svelte.d.ts +4 -0
  101. package/dist/svelte/routes/AssetManagerRoute.svelte.d.ts.map +1 -0
  102. package/dist/svelte/routes/index.d.ts +2 -0
  103. package/dist/svelte/routes/index.d.ts.map +1 -0
  104. package/dist/svelte/routes/index.js +1 -0
  105. package/dist/svelte/routes/shared.d.ts +25 -0
  106. package/dist/svelte/routes/shared.d.ts.map +1 -0
  107. package/dist/svelte/routes/shared.js +31 -0
  108. package/dist/svelte/types.d.ts +179 -0
  109. package/dist/svelte/types.d.ts.map +1 -0
  110. package/dist/svelte/types.js +6 -0
  111. package/dist/types.d.ts +80 -0
  112. package/dist/types.d.ts.map +1 -0
  113. package/dist/types.js +2 -0
  114. package/dist/types.js.map +1 -0
  115. package/dist/ui.d.ts +10 -0
  116. package/dist/ui.d.ts.map +1 -0
  117. package/dist/ui.js +85 -0
  118. package/dist/ui.js.map +1 -0
  119. package/package.json +102 -0
@@ -0,0 +1,28 @@
1
+ import { SmrtCollection } from '@happyvertical/smrt-core';
2
+ import { AssetType } from './asset-type';
3
+ export declare class AssetTypeCollection extends SmrtCollection<AssetType> {
4
+ static readonly _itemClass: typeof AssetType;
5
+ /**
6
+ * Get or create an asset type by slug
7
+ *
8
+ * @param slug - The asset type slug
9
+ * @param name - The display name (defaults to slug)
10
+ * @param description - Optional description
11
+ * @returns The existing or newly created AssetType
12
+ */
13
+ getOrCreate(slug: string, name?: string, description?: string): Promise<AssetType>;
14
+ /**
15
+ * Initialize common asset types
16
+ *
17
+ * Creates standard asset types if they don't exist:
18
+ * - image
19
+ * - video
20
+ * - document
21
+ * - audio
22
+ *
23
+ * Note: `folder` was removed in R3-D. Folders are no longer an asset
24
+ * subtype — they live on their own `folders` table. See `folder.ts`.
25
+ */
26
+ initializeCommonTypes(): Promise<void>;
27
+ }
28
+ //# sourceMappingURL=asset-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-types.d.ts","sourceRoot":"","sources":["../src/asset-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,SAAS,CAAC;IAChE,MAAM,CAAC,QAAQ,CAAC,UAAU,mBAAa;IAEvC;;;;;;;OAOG;IACG,WAAW,CACf,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,SAAS,CAAC;IAarB;;;;;;;;;;;OAWG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;CAsB7C"}
@@ -0,0 +1,158 @@
1
+ import { SmrtObject } from '@happyvertical/smrt-core';
2
+ import { Tag } from '@happyvertical/smrt-tags';
3
+ import { AssetAssociation } from './asset-association';
4
+ import { AssetStatus } from './asset-status';
5
+ import { AssetType } from './asset-type';
6
+ import { AssetOptions } from './types';
7
+ export interface AssetExternalReference {
8
+ provider: string;
9
+ assetId?: string | null;
10
+ externalId?: string | null;
11
+ sourceRef?: Record<string, unknown> | null;
12
+ status?: string | null;
13
+ metadata?: Record<string, unknown> | null;
14
+ syncedAt?: string | null;
15
+ [key: string]: unknown;
16
+ }
17
+ export declare class Asset extends SmrtObject {
18
+ tenantId: string | null;
19
+ name: string;
20
+ sourceUri: string;
21
+ mimeType: string;
22
+ description: string;
23
+ metadata: string;
24
+ version: number;
25
+ primaryVersionId: string | null;
26
+ typeSlug: string;
27
+ statusSlug: string;
28
+ ownerProfileId: string | null;
29
+ /**
30
+ * FK to the source Asset this one was derived from (e.g. thumbnail
31
+ * derived from an original image, transcoded video, AI variation).
32
+ *
33
+ * Renamed from `parentId` in R3-D to make the derivation semantics
34
+ * explicit and free `parentId` to mean exactly structural hierarchy
35
+ * (SmrtHierarchical) across the framework. The column on the assets
36
+ * table is `source_asset_id`.
37
+ */
38
+ sourceAssetId: string | null;
39
+ folderId: string | null;
40
+ sourceType: string;
41
+ externalId: string;
42
+ externalRefs: string;
43
+ createdAt: Date;
44
+ updatedAt: Date;
45
+ constructor(options?: AssetOptions);
46
+ getMetadata(): Record<string, unknown>;
47
+ setMetadata(metadata: Record<string, unknown>): void;
48
+ mergeMetadata(metadata: Record<string, unknown>): void;
49
+ getExternalRefs(): Record<string, AssetExternalReference>;
50
+ getExternalRef(provider: string): AssetExternalReference | null;
51
+ setExternalRef(provider: string, reference: Omit<AssetExternalReference, 'provider'> & {
52
+ provider?: string;
53
+ }): void;
54
+ /**
55
+ * Get all tags for this asset from @happyvertical/smrt-tags
56
+ *
57
+ * @returns Array of Tag instances from @happyvertical/smrt-tags package
58
+ */
59
+ getTags(): Promise<Tag[]>;
60
+ /**
61
+ * Check if this asset has a specific tag
62
+ *
63
+ * @param tagSlug - The slug of the tag to check
64
+ * @returns True if the asset has this tag
65
+ */
66
+ hasTag(tagSlug: string): Promise<boolean>;
67
+ /**
68
+ * Resolve the AssetCollection lazily. Going through `ObjectRegistry`
69
+ * mirrors the pattern used by `SmrtHierarchical._hierarchyCollection`
70
+ * so source/derivative lookups inherit tenant scoping and ORM
71
+ * hydration without hard-coding an import of `./assets` (which would
72
+ * create a module-import cycle).
73
+ *
74
+ * The return type is `SmrtCollection<Asset>` (the framework base, type-
75
+ * only import from core) rather than the concrete `AssetCollection` —
76
+ * importing the concrete class is what would create the cycle, but the
77
+ * base-class shape gives callers full `.get()` / `.list()` type
78
+ * safety here.
79
+ *
80
+ * R5-canon: hardcode the base Asset's qualified key so a different
81
+ * package also registering a class called `Asset` can't be picked
82
+ * by `findClass`'s multi-strategy fallback. Crucially we DON'T
83
+ * resolve via `this.constructor._smrtQualifiedName` — for an STI
84
+ * subclass like `Image`, that would yield the Image collection
85
+ * (which auto-filters `_meta_type = '...:Image'` on `get`/`list`),
86
+ * and `getSource()` / `getDerivatives()` would miss cross-type
87
+ * derivation links (Image derived from a plain Asset, etc.).
88
+ * `sourceAssetId` is a base-table derivation link, so it always
89
+ * resolves through the base Asset collection.
90
+ */
91
+ private _assetCollection;
92
+ /**
93
+ * Get the source asset this one was derived from, if any.
94
+ *
95
+ * Renamed from `getParent` in R3-D. The relationship is "I was produced
96
+ * from that asset" (e.g. a thumbnail's source is its original image),
97
+ * not a structural-hierarchy parent.
98
+ *
99
+ * Goes through the AssetCollection so tenant interceptors and ORM
100
+ * hydration apply — important because a tenant-scoped consumer with
101
+ * cross-tenant derivative chains would otherwise return assets from
102
+ * tenants the caller cannot see, and a raw `db.get` returns
103
+ * snake_case rows that leave camelCase props (e.g. `sourceUri`) at
104
+ * their constructor defaults.
105
+ *
106
+ * @returns Source Asset instance, or null if this asset has no source
107
+ */
108
+ getSource(): Promise<Asset | null>;
109
+ /**
110
+ * Get all assets derived from this one (e.g. thumbnails, variants,
111
+ * transcodes, AI edits).
112
+ *
113
+ * Renamed from `getChildren` in R3-D to match the derivation
114
+ * semantics. Goes through the AssetCollection so tenant interceptors
115
+ * and ORM hydration apply (see `getSource` for why this matters —
116
+ * the pre-R3-D `getChildren` used raw `db.list`, which both bypassed
117
+ * tenant scoping and dropped camelCase property hydration; that
118
+ * latent breakage is fixed here).
119
+ *
120
+ * @returns Array of derivative Asset instances
121
+ */
122
+ getDerivatives(): Promise<Asset[]>;
123
+ /**
124
+ * Get the type of this asset
125
+ *
126
+ * @returns AssetType instance or null
127
+ */
128
+ getType(): Promise<AssetType | null>;
129
+ /**
130
+ * Get the status of this asset
131
+ *
132
+ * @returns AssetStatus instance or null
133
+ */
134
+ getStatus(): Promise<AssetStatus | null>;
135
+ /**
136
+ * Get all associations for this asset
137
+ *
138
+ * @returns Array of AssetAssociation instances
139
+ */
140
+ getAssociations(): Promise<AssetAssociation[]>;
141
+ /**
142
+ * Associate this asset with a target object
143
+ *
144
+ * @param metaType - Target class name or qualified name (e.g., 'Article' or '@pkg:Article')
145
+ * @param metaId - Target object ID
146
+ * @param role - Association role (default: 'default')
147
+ * @returns The created AssetAssociation
148
+ */
149
+ associateWith(metaType: string, metaId: string, role?: string): Promise<AssetAssociation>;
150
+ /**
151
+ * Get asset by slug
152
+ *
153
+ * @param slug - The slug to search for
154
+ * @returns Asset instance or null
155
+ */
156
+ static getBySlug(_slug: string): Promise<Asset | null>;
157
+ }
158
+ //# sourceMappingURL=asset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset.d.ts","sourceRoot":"","sources":["../src/asset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OA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IAAI,SAAY,GACf,OAAO,CAAC,gBAAgB,CAAC;IAO5B;;;;;OAKG;WACU,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;CAI7D"}
@@ -0,0 +1,125 @@
1
+ import { SmrtCollection } from '@happyvertical/smrt-core';
2
+ import { Asset } from './asset';
3
+ export declare class AssetCollection extends SmrtCollection<Asset> {
4
+ static readonly _itemClass: typeof Asset;
5
+ /**
6
+ * Find all assets belonging to a specific tenant
7
+ *
8
+ * @param tenantId - The tenant ID to filter by
9
+ * @returns Array of assets belonging to this tenant
10
+ */
11
+ findByTenant(tenantId: string): Promise<Asset[]>;
12
+ /**
13
+ * Find all global assets (assets without a tenant)
14
+ *
15
+ * @returns Array of global assets
16
+ */
17
+ findGlobal(): Promise<Asset[]>;
18
+ /**
19
+ * Find assets belonging to a tenant plus all global assets
20
+ *
21
+ * @param tenantId - The tenant ID to include
22
+ * @returns Array of tenant-specific and global assets
23
+ */
24
+ findWithGlobals(tenantId: string): Promise<Asset[]>;
25
+ /**
26
+ * Add a tag to an asset (uses @smrt/tags)
27
+ *
28
+ * @param assetId - The asset ID to tag
29
+ * @param tagSlug - The tag slug from @smrt/tags
30
+ */
31
+ addTag(assetId: string, tagSlug: string): Promise<void>;
32
+ /**
33
+ * Remove a tag from an asset
34
+ *
35
+ * @param assetId - The asset ID
36
+ * @param tagSlug - The tag slug to remove
37
+ */
38
+ removeTag(assetId: string, tagSlug: string): Promise<void>;
39
+ /**
40
+ * Get all assets with a specific tag
41
+ *
42
+ * @param tagSlug - The tag slug to filter by
43
+ * @returns Array of assets with this tag
44
+ */
45
+ getByTag(tagSlug: string): Promise<Asset[]>;
46
+ /**
47
+ * Get assets by type
48
+ *
49
+ * @param typeSlug - The asset type slug (e.g., 'image', 'video')
50
+ * @returns Array of assets matching the type
51
+ */
52
+ getByType(typeSlug: string): Promise<Asset[]>;
53
+ /**
54
+ * Get assets by status
55
+ *
56
+ * @param statusSlug - The asset status slug (e.g., 'published', 'draft')
57
+ * @returns Array of assets matching the status
58
+ */
59
+ getByStatus(statusSlug: string): Promise<Asset[]>;
60
+ /**
61
+ * Get assets by owner
62
+ *
63
+ * @param ownerProfileId - The profile ID of the owner
64
+ * @returns Array of assets owned by this profile
65
+ */
66
+ getByOwner(ownerProfileId: string): Promise<Asset[]>;
67
+ /**
68
+ * Create a new version of an existing asset
69
+ *
70
+ * @param primaryVersionId - The primary version ID (first version's ID)
71
+ * @param newSourceUri - The new source URI for this version
72
+ * @param updates - Optional additional updates
73
+ * @returns The newly created asset version
74
+ */
75
+ createNewVersion(primaryVersionId: string, newSourceUri: string, updates?: Partial<Asset>): Promise<Asset>;
76
+ /**
77
+ * Get the latest version of an asset
78
+ *
79
+ * @param primaryVersionId - The primary version ID
80
+ * @returns The latest version or null
81
+ */
82
+ getLatestVersion(primaryVersionId: string): Promise<Asset | null>;
83
+ /**
84
+ * List all versions of an asset
85
+ *
86
+ * @param primaryVersionId - The primary version ID
87
+ * @returns Array of all asset versions, ordered by version number
88
+ */
89
+ listVersions(primaryVersionId: string): Promise<Asset[]>;
90
+ /**
91
+ * Get derivative assets of a source asset.
92
+ *
93
+ * Renamed from `getChildren(parentId)` in R3-D to match the rename of
94
+ * the underlying column (`parent_id` → `source_asset_id`) and method
95
+ * (`Asset.getChildren` → `Asset.getDerivatives`).
96
+ *
97
+ * @param sourceAssetId - The source asset ID
98
+ * @returns Array of derivative assets
99
+ */
100
+ getDerivatives(sourceAssetId: string): Promise<Asset[]>;
101
+ /**
102
+ * Get assets by MIME type pattern
103
+ *
104
+ * @param mimePattern - MIME type pattern (e.g., 'image/*', 'video/mp4')
105
+ * @returns Array of matching assets
106
+ */
107
+ getByMimeType(mimePattern: string): Promise<Asset[]>;
108
+ /**
109
+ * Rollback to a previous version by creating a new version with the target's content.
110
+ * Does NOT delete intermediate versions (safe rollback).
111
+ *
112
+ * @param primaryVersionId - The primary version ID of the version chain
113
+ * @param targetVersion - The version number to rollback to
114
+ * @returns The newly created asset version with content copied from target
115
+ */
116
+ rollbackToVersion(primaryVersionId: string, targetVersion: number): Promise<Asset>;
117
+ /**
118
+ * Get assets in a specific folder
119
+ *
120
+ * @param folderId - The folder ID to list contents for
121
+ * @returns Array of assets in this folder
122
+ */
123
+ getByFolder(folderId: string): Promise<Asset[]>;
124
+ }
125
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../src/assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,eAAgB,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,MAAM,CAAC,QAAQ,CAAC,UAAU,eAAS;IAMnC;;;;;OAKG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAItD;;;;OAIG;IACG,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAIpC;;;;;OAKG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAOzD;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7D;;;;;OAKG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhE;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAgBjD;;;;;OAKG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAInD;;;;;OAKG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAIvD;;;;;OAKG;IACG,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAI1D;;;;;;;OAOG;IACG,gBAAgB,CACpB,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,OAAO,CAAC,KAAK,CAAM,GAC3B,OAAO,CAAC,KAAK,CAAC;IAkDjB;;;;;OAKG;IACG,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IASvE;;;;;OAKG;IACG,YAAY,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAsB9D;;;;;;;;;OASG;IACG,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAI7D;;;;;OAKG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAS1D;;;;;;;OAOG;IACG,iBAAiB,CACrB,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,KAAK,CAAC;IAgBjB;;;;;OAKG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAGtD"}
@@ -0,0 +1,16 @@
1
+ import { SmrtHierarchical } from '@happyvertical/smrt-core';
2
+ import { FolderOptions } from './types';
3
+ export declare class Folder extends SmrtHierarchical {
4
+ tenantId: string | null;
5
+ name: string;
6
+ description: string;
7
+ ownerProfileId: string | null;
8
+ createdAt: Date;
9
+ updatedAt: Date;
10
+ constructor(options?: FolderOptions);
11
+ /**
12
+ * Look up a folder by slug.
13
+ */
14
+ static getBySlug(_slug: string): Promise<Folder | null>;
15
+ }
16
+ //# sourceMappingURL=folder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../src/folder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAEL,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAMa,MAAO,SAAQ,gBAAgB;IAI1C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAG/B,IAAI,SAAM;IAEV,WAAW,SAAM;IAEjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAQ;IAGrC,SAAS,OAAc;IACvB,SAAS,OAAc;gBAEX,OAAO,GAAE,aAAkB;IAkBvC;;OAEG;WACU,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAI9D"}
@@ -0,0 +1,45 @@
1
+ import { SmrtCollection } from '@happyvertical/smrt-core';
2
+ import { Asset } from './asset';
3
+ import { AssetCollection } from './assets';
4
+ import { Folder } from './folder';
5
+ export declare class FolderCollection extends SmrtCollection<Folder> {
6
+ static readonly _itemClass: typeof Folder;
7
+ /**
8
+ * Get the folder tree starting from an optional root.
9
+ *
10
+ * When `rootId` is omitted, returns top-level folders (those with no
11
+ * parent). When `rootId` is provided, returns all descendants of that
12
+ * folder via the inherited SmrtHierarchical BFS traversal — same
13
+ * cycle-safe, one-query-per-depth behaviour as Place/Event.
14
+ *
15
+ * @param rootId - Optional root folder ID; if omitted, returns top-level folders
16
+ * @returns Array of folders (flat list; use parentId to reconstruct tree)
17
+ */
18
+ getTree(rootId?: string): Promise<Folder[]>;
19
+ /**
20
+ * Get the path from root to a given folder (ancestors + self).
21
+ *
22
+ * @param folderId - The folder ID to get the path for
23
+ * @returns Array of folders from root to the given folder (inclusive)
24
+ */
25
+ getPath(folderId: string): Promise<Folder[]>;
26
+ /**
27
+ * Get all assets that are direct children of a folder.
28
+ *
29
+ * Folder membership is recorded on `Asset.folderId`, not on the folder
30
+ * itself, so this is delegated to the asset collection.
31
+ *
32
+ * @param folderId - The folder ID
33
+ * @param assetCollection - An AssetCollection instance for querying
34
+ * @returns Array of assets in this folder
35
+ */
36
+ getContents(folderId: string, assetCollection: AssetCollection): Promise<Asset[]>;
37
+ /**
38
+ * Move an asset into a folder (or out, by passing `null`).
39
+ *
40
+ * @param asset - The asset to move
41
+ * @param folderId - The target folder ID (or null to move to root)
42
+ */
43
+ moveAsset(asset: Asset, folderId: string | null): Promise<void>;
44
+ }
45
+ //# sourceMappingURL=folders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folders.d.ts","sourceRoot":"","sources":["../src/folders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAC1D,MAAM,CAAC,QAAQ,CAAC,UAAU,gBAAU;IAEpC;;;;;;;;;;OAUG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAsCjD;;;;;OAKG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAOlD;;;;;;;;;OASG;IACG,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;IAMnB;;;;;OAKG;IACG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAItE"}
@@ -0,0 +1,21 @@
1
+ export { Asset } from './asset';
2
+ export { AssetAssociation } from './asset-association';
3
+ export { AssetAssociationCollection } from './asset-associations';
4
+ export { type AssetCapabilityName, type AssetCapabilityProvider, type AssetCapabilityRuntime, AssetCapabilitySkippedError, type AssetCapabilitySource, AssetCapabilityUnavailableError, type AssetEnsureVariantInput, type AssetExternalSourceRef, type AssetExternalSyncInput, type AssetExternalSyncResult, type AssetNearbySearchInput, type AssetProcessInput, type AssetProcessResult, type AssetSearchItem, type AssetSearchResult, type AssetVariantFit, type AssetVariantRequest, type AssetVariantResult, type AssetWorkflowInput, type AssetWorkflowInputSelection, type AssetWorkflowResult, } from './asset-capabilities';
5
+ export { ASSET_EXTRACTION_STATUS, ASSET_METADATA_KEYS, ASSET_ROLES, type AssetExtractionStatus, type AssetMetadataKey, type AssetRole, } from './asset-conventions';
6
+ export { AssetMetafield } from './asset-metafield';
7
+ export { AssetMetafieldCollection } from './asset-metafields';
8
+ export { AssetRuntime, type AssetRuntimeDb, type AssetRuntimeLike, type AssetRuntimeOptions, createAssetRuntime, type LinkDerivationOptions, type StoreDerivedAssetOptions, } from './asset-runtime';
9
+ export { AssetServeError, type ResolvedAssetBytes, resolveAssetForServing, type ServeAssetOptions, serveAsset, } from './asset-serving';
10
+ export { AssetStatus } from './asset-status';
11
+ export { AssetStatusCollection } from './asset-statuses';
12
+ export { type AssetStorageOperation, type AssetStorageResolution, type AssetStorageResolveRequest, type AssetStorageResolver, AssetStore, type AssetStoreOptions, type ProviderOptions, type StoreOptions, } from './asset-store';
13
+ export { AssetType } from './asset-type';
14
+ export { AssetTypeCollection } from './asset-types';
15
+ export { AssetCollection } from './assets';
16
+ export { Folder } from './folder';
17
+ export { FolderCollection } from './folders';
18
+ export { type MediaBundleFileDescriptor, type MediaBundleGpsTrackPoint, type MediaBundleInspection, type MediaBundleInspectionLike, type MediaBundleNormalizedMetadata, type MediaBundleSupportFileInspection, type MediaSupportFileVisibility, type PersistMediaBundleAssetInput, type PersistMediaBundleAssociationInput, type PersistMediaBundleInspectionOptions, type PersistMediaBundleInspectionResult, type PersistMediaBundleMetadataArtifactInput, persistMediaBundleInspection, type SmrtMediaBundlePersistenceAdapter, } from './media-bundle-persistence';
19
+ export { type AssetOwnerCollection, type AssetOwnerRecord, addOwnedAssetFromCollection, assertValidOwnedAssetRelationship, assertValidOwnedAssetSortOrder, getOwnedAssetsFromCollection, OWNED_ASSET_RELATIONSHIP_PATTERN, removeOwnedAssetFromCollection, resolveOwnedAssetsById, } from './owned-asset-helpers';
20
+ export type { AssetAssociationOptions, AssetMetafieldOptions, AssetOptions, AssetStatusOptions, AssetTypeOptions, FolderOptions, } from './types';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,wBAAwB,CAAC;AAGhC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,2BAA2B,EAC3B,KAAK,qBAAqB,EAC1B,+BAA+B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,WAAW,EACX,KAAK,qBA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