@happyvertical/smrt-content 0.33.1 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contents.d.ts +9 -2
- package/dist/contents.d.ts.map +1 -1
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/smrt-knowledge.json +4 -4
- package/package.json +14 -14
package/dist/contents.d.ts
CHANGED
|
@@ -263,7 +263,11 @@ export declare class Contents extends SmrtCollection<Content> {
|
|
|
263
263
|
*/
|
|
264
264
|
findByTenant(tenantId: string): Promise<Content[]>;
|
|
265
265
|
/**
|
|
266
|
-
* Find all global content (not associated with any tenant)
|
|
266
|
+
* Find all global content (not associated with any tenant).
|
|
267
|
+
*
|
|
268
|
+
* Routes through the shared tenant-global helper so it does not throw under
|
|
269
|
+
* an active tenant context (an explicit `tenant_id IS NULL` filter would be
|
|
270
|
+
* flagged as an isolation violation). (#1600)
|
|
267
271
|
*
|
|
268
272
|
* @returns Promise resolving to array of global Content objects
|
|
269
273
|
*
|
|
@@ -274,11 +278,14 @@ export declare class Contents extends SmrtCollection<Content> {
|
|
|
274
278
|
*/
|
|
275
279
|
findGlobal(): Promise<Content[]>;
|
|
276
280
|
/**
|
|
277
|
-
* Find content for a tenant including global content
|
|
281
|
+
* Find content for a tenant including global content.
|
|
278
282
|
*
|
|
279
283
|
* This returns both tenant-specific content and global content (tenantId is null),
|
|
280
284
|
* useful for showing a tenant their content plus any shared/global resources.
|
|
281
285
|
*
|
|
286
|
+
* Fails closed if an active tenant context requests a different tenant's
|
|
287
|
+
* rows; the admin/system path keeps the cross-tenant capability. (#1600)
|
|
288
|
+
*
|
|
282
289
|
* @param tenantId - The tenant ID to include
|
|
283
290
|
* @returns Promise resolving to array of Content objects (tenant + global)
|
|
284
291
|
*
|
package/dist/contents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contents.d.ts","sourceRoot":"","sources":["../src/contents.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAQ,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"contents.d.ts","sourceRoot":"","sources":["../src/contents.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAQ,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAKxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAI/B;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAaD;;;;;;GAMG;AACH,qBAkCa,QAAS,SAAQ,cAAc,CAAC,OAAO,CAAC;IACnD;;OAEG;IACH,MAAM,CAAC,UAAU,iBAAW;IAE5B;;OAEG;IACI,OAAO,EAAE,eAAe,CAAyB;IAExD;;OAEG;IACI,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACI,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpC;;;;;;OAMG;gBACS,OAAO,GAAE,eAAoB;IAMzC;;;;OAIG;IACH,KAAK;IAIL;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAK1B,iBAAiB;IAKlB,WAAW,CACtB,OAAO,GAAE;QACP,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,KAAK,CAAC,EAAE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FORMAT, bodyToEditorHtml, editorHtmlToBody, extrac
|
|
|
4
4
|
import { AssetCollection, AssetStatusCollection, AssetTypeCollection } from "@happyvertical/smrt-assets";
|
|
5
5
|
import { ImageCollection } from "@happyvertical/smrt-images";
|
|
6
6
|
import { definePrompt, resolvePrompt } from "@happyvertical/smrt-prompts";
|
|
7
|
-
import { tenantId, TenantScoped } from "@happyvertical/smrt-tenancy";
|
|
7
|
+
import { tenantId, TenantScoped, queryGlobal, queryWithGlobals } from "@happyvertical/smrt-tenancy";
|
|
8
8
|
import { fetchStaticMap } from "@happyvertical/geo";
|
|
9
9
|
import { generateHeadlineCard } from "@happyvertical/images";
|
|
10
10
|
import { getAI } from "@happyvertical/ai";
|
|
@@ -10360,7 +10360,11 @@ let Contents = class extends SmrtCollection {
|
|
|
10360
10360
|
return this.list({ where: { tenantId: tenantId2 } });
|
|
10361
10361
|
}
|
|
10362
10362
|
/**
|
|
10363
|
-
* Find all global content (not associated with any tenant)
|
|
10363
|
+
* Find all global content (not associated with any tenant).
|
|
10364
|
+
*
|
|
10365
|
+
* Routes through the shared tenant-global helper so it does not throw under
|
|
10366
|
+
* an active tenant context (an explicit `tenant_id IS NULL` filter would be
|
|
10367
|
+
* flagged as an isolation violation). (#1600)
|
|
10364
10368
|
*
|
|
10365
10369
|
* @returns Promise resolving to array of global Content objects
|
|
10366
10370
|
*
|
|
@@ -10370,14 +10374,17 @@ let Contents = class extends SmrtCollection {
|
|
|
10370
10374
|
* ```
|
|
10371
10375
|
*/
|
|
10372
10376
|
async findGlobal() {
|
|
10373
|
-
return this
|
|
10377
|
+
return queryGlobal(this);
|
|
10374
10378
|
}
|
|
10375
10379
|
/**
|
|
10376
|
-
* Find content for a tenant including global content
|
|
10380
|
+
* Find content for a tenant including global content.
|
|
10377
10381
|
*
|
|
10378
10382
|
* This returns both tenant-specific content and global content (tenantId is null),
|
|
10379
10383
|
* useful for showing a tenant their content plus any shared/global resources.
|
|
10380
10384
|
*
|
|
10385
|
+
* Fails closed if an active tenant context requests a different tenant's
|
|
10386
|
+
* rows; the admin/system path keeps the cross-tenant capability. (#1600)
|
|
10387
|
+
*
|
|
10381
10388
|
* @param tenantId - The tenant ID to include
|
|
10382
10389
|
* @returns Promise resolving to array of Content objects (tenant + global)
|
|
10383
10390
|
*
|
|
@@ -10387,10 +10394,7 @@ let Contents = class extends SmrtCollection {
|
|
|
10387
10394
|
* ```
|
|
10388
10395
|
*/
|
|
10389
10396
|
async findWithGlobals(tenantId2) {
|
|
10390
|
-
return this.
|
|
10391
|
-
`SELECT * FROM ${this.tableName} WHERE tenant_id = ? OR tenant_id IS NULL`,
|
|
10392
|
-
[tenantId2]
|
|
10393
|
-
);
|
|
10397
|
+
return queryWithGlobals(this, tenantId2, "Content.findWithGlobals");
|
|
10394
10398
|
}
|
|
10395
10399
|
};
|
|
10396
10400
|
__publicField(Contents, "_itemClass", Content);
|