@happyvertical/smrt-content 0.56.0 → 0.56.2

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.
@@ -2,21 +2,21 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { SmrtCollection, SmrtObject, crossPackageRef, foreignKey, smrt } from "@happyvertical/smrt-core";
3
3
  import { TenantScoped, tenantId } from "@happyvertical/smrt-tenancy";
4
4
  //#region src/content-correction.ts
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
5
+ var __defProp$1 = Object.defineProperty;
6
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
7
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, {
8
8
  enumerable: true,
9
9
  configurable: true,
10
10
  writable: true,
11
11
  value
12
12
  }) : obj[key] = value;
13
- var __decorateClass = (decorators, target, key, kind) => {
14
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
13
+ var __decorateClass$1 = (decorators, target, key, kind) => {
14
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
15
15
  for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
16
- if (kind && result) __defProp(target, key, result);
16
+ if (kind && result) __defProp$1(target, key, result);
17
17
  return result;
18
18
  };
19
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
20
20
  var ContentCorrection = class extends SmrtObject {
21
21
  contentId = "";
22
22
  contentVersionId = "";
@@ -59,16 +59,16 @@ var ContentCorrection = class extends SmrtObject {
59
59
  }
60
60
  }
61
61
  };
62
- __publicField(ContentCorrection, "__smrtPackage__", "@happyvertical/smrt-content");
63
- __decorateClass([foreignKey("Content", {
62
+ __publicField$1(ContentCorrection, "__smrtPackage__", "@happyvertical/smrt-content");
63
+ __decorateClass$1([foreignKey("Content", {
64
64
  required: true,
65
65
  onDelete: "CASCADE"
66
66
  })], ContentCorrection.prototype, "contentId", 2);
67
- __decorateClass([foreignKey("ContentVersion", { onDelete: "CASCADE" })], ContentCorrection.prototype, "contentVersionId", 2);
68
- __decorateClass([crossPackageRef("@happyvertical/smrt-facts:Fact")], ContentCorrection.prototype, "factId", 2);
69
- __decorateClass([crossPackageRef("@happyvertical/smrt-facts:Fact")], ContentCorrection.prototype, "replacementFactId", 2);
70
- __decorateClass([tenantId({ nullable: true })], ContentCorrection.prototype, "tenantId", 2);
71
- ContentCorrection = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
67
+ __decorateClass$1([foreignKey("ContentVersion", { onDelete: "CASCADE" })], ContentCorrection.prototype, "contentVersionId", 2);
68
+ __decorateClass$1([crossPackageRef("@happyvertical/smrt-facts:Fact")], ContentCorrection.prototype, "factId", 2);
69
+ __decorateClass$1([crossPackageRef("@happyvertical/smrt-facts:Fact")], ContentCorrection.prototype, "replacementFactId", 2);
70
+ __decorateClass$1([tenantId({ nullable: true })], ContentCorrection.prototype, "tenantId", 2);
71
+ ContentCorrection = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
72
72
  tableName: "content_corrections",
73
73
  api: { include: [
74
74
  "list",
@@ -87,8 +87,22 @@ ContentCorrection = __decorateClass([TenantScoped({ mode: "optional" }), smrt({
87
87
  //#endregion
88
88
  //#region src/content-corrections.ts
89
89
  var content_corrections_exports = /* @__PURE__ */ __exportAll({ ContentCorrectionCollection: () => ContentCorrectionCollection });
90
+ var __defProp = Object.defineProperty;
91
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
92
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value
97
+ }) : obj[key] = value;
98
+ var __decorateClass = (decorators, target, key, kind) => {
99
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
100
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
101
+ if (kind && result) __defProp(target, key, result);
102
+ return result;
103
+ };
104
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
90
105
  var ContentCorrectionCollection = class extends SmrtCollection {
91
- static _itemClass = ContentCorrection;
92
106
  async listForContent(contentId) {
93
107
  return this.list({
94
108
  where: { contentId },
@@ -112,7 +126,28 @@ var ContentCorrectionCollection = class extends SmrtCollection {
112
126
  });
113
127
  }
114
128
  };
129
+ __publicField(ContentCorrectionCollection, "__smrtPackage__", "@happyvertical/smrt-content");
130
+ __publicField(ContentCorrectionCollection, "_itemClass", ContentCorrection);
131
+ ContentCorrectionCollection = __decorateClass([smrt({
132
+ tableName: "content_corrections",
133
+ api: { include: [
134
+ "list",
135
+ "get",
136
+ "create",
137
+ "update",
138
+ "listForContent",
139
+ "getPublishedForContent"
140
+ ] },
141
+ mcp: { include: [
142
+ "list",
143
+ "get",
144
+ "create",
145
+ "update",
146
+ "listForContent",
147
+ "getPublishedForContent"
148
+ ] }
149
+ })], ContentCorrectionCollection);
115
150
  //#endregion
116
151
  export { content_corrections_exports as n, ContentCorrection as r, ContentCorrectionCollection as t };
117
152
 
118
- //# sourceMappingURL=content-corrections-DBYUJDaD.js.map
153
+ //# sourceMappingURL=content-corrections-BYT3Qdw5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-corrections-BYT3Qdw5.js","names":[],"sources":["../../src/content-correction.ts","../../src/content-corrections.ts"],"sourcesContent":["import type { SmrtObjectOptions } from '@happyvertical/smrt-core';\nimport {\n crossPackageRef,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type {\n ContentCorrectionStatus,\n ContentCorrectionType,\n} from './content-governance';\n\nexport interface ContentCorrectionOptions extends SmrtObjectOptions {\n contentId?: string;\n contentVersionId?: string;\n factId?: string;\n replacementFactId?: string;\n correctionType?: ContentCorrectionType;\n status?: ContentCorrectionStatus;\n summary?: string;\n incorrectText?: string;\n correctedText?: string;\n publicNote?: string;\n metadata?: string | Record<string, unknown>;\n tenantId?: string | null;\n publishedAt?: Date | null;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'content_corrections',\n api: { include: ['list', 'get', 'create', 'update'] },\n mcp: { include: ['list', 'get', 'create', 'update'] },\n cli: { skipApiCheck: true },\n})\nexport class ContentCorrection extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-content\";\n @foreignKey('Content', { required: true, onDelete: 'CASCADE' })\n contentId = '';\n\n @foreignKey('ContentVersion', { onDelete: 'CASCADE' })\n contentVersionId = '';\n\n @crossPackageRef('@happyvertical/smrt-facts:Fact')\n factId = '';\n\n @crossPackageRef('@happyvertical/smrt-facts:Fact')\n replacementFactId = '';\n correctionType: ContentCorrectionType = 'fact';\n status: ContentCorrectionStatus = 'draft';\n summary = '';\n incorrectText = '';\n correctedText = '';\n publicNote = '';\n metadata = '';\n\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n publishedAt: Date | null = null;\n createdAt = new Date();\n updatedAt = new Date();\n\n constructor(options: ContentCorrectionOptions = {}) {\n super(options);\n if (options.contentId) this.contentId = options.contentId;\n if (options.contentVersionId !== undefined)\n this.contentVersionId = options.contentVersionId;\n if (options.factId !== undefined) this.factId = options.factId;\n if (options.replacementFactId !== undefined)\n this.replacementFactId = options.replacementFactId;\n if (options.correctionType !== undefined)\n this.correctionType = options.correctionType;\n if (options.status !== undefined) this.status = options.status;\n if (options.summary !== undefined) this.summary = options.summary;\n if (options.incorrectText !== undefined)\n this.incorrectText = options.incorrectText;\n if (options.correctedText !== undefined)\n this.correctedText = options.correctedText;\n if (options.publicNote !== undefined) this.publicNote = options.publicNote;\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.publishedAt !== undefined)\n this.publishedAt = options.publishedAt;\n if (options.createdAt) this.createdAt = options.createdAt;\n if (options.updatedAt) this.updatedAt = options.updatedAt;\n\n if (options.metadata !== undefined) {\n this.metadata =\n typeof options.metadata === 'string'\n ? options.metadata\n : JSON.stringify(options.metadata);\n }\n }\n\n getMetadata(): Record<string, unknown> {\n try {\n return this.metadata ? JSON.parse(this.metadata) : {};\n } catch {\n return {};\n }\n }\n}\n","import { SmrtCollection, smrt } from '@happyvertical/smrt-core';\nimport { ContentCorrection } from './content-correction';\n\n// The collection's own @smrt() surface: its read helpers are published\n// operations (the API explorer and the workbench call them). A collection\n// inherits only its model's CRUD verbs, so it lists the helpers it opens here.\n// The CRUD verbs repeat the model's because a collection decorator's config\n// is merged over its model's at runtime.\n@smrt({\n // Mirror the model's storage so the collection decorator cannot plan a\n // different table for it.\n tableName: 'content_corrections',\n api: {\n include: [\n 'list',\n 'get',\n 'create',\n 'update',\n 'listForContent',\n 'getPublishedForContent',\n ],\n },\n mcp: {\n include: [\n 'list',\n 'get',\n 'create',\n 'update',\n 'listForContent',\n 'getPublishedForContent',\n ],\n },\n})\nexport class ContentCorrectionCollection extends SmrtCollection<ContentCorrection> { static __smrtPackage__ = \"@happyvertical/smrt-content\";\n static readonly _itemClass = ContentCorrection;\n\n async listForContent(contentId: string): Promise<ContentCorrection[]> {\n return this.list({\n where: { contentId },\n orderBy: 'created_at DESC',\n });\n }\n\n async getPublishedForContent(\n contentId: string,\n ): Promise<ContentCorrection[]> {\n return this.list({\n where: { contentId, status: 'published' },\n orderBy: 'published_at DESC',\n });\n }\n\n async issue(\n options: ConstructorParameters<typeof ContentCorrection>[0],\n ): Promise<ContentCorrection> {\n if (!options) {\n return this.create({});\n }\n\n return this.create({\n ...options,\n metadata:\n typeof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