@bernierllc/content-management-suite 0.10.0 → 2.0.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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +68 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -51
- package/dist/index.mjs.map +1 -1
- package/dist/prisma.d.mts +1 -1
- package/dist/prisma.d.ts +1 -1
- package/dist/{types-DQpwJ5e3.d.ts → types-DQNP3lLP.d.ts} +31 -13
- package/dist/utils.js +6 -6
- package/dist/utils.js.map +1 -1
- package/dist/utils.mjs +6 -6
- package/dist/utils.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -127,16 +127,16 @@ var ContentManagementConfigSchema = z.object({
|
|
|
127
127
|
|
|
128
128
|
// src/errors.ts
|
|
129
129
|
var ContentManagementError = class extends Error {
|
|
130
|
+
code;
|
|
131
|
+
context;
|
|
130
132
|
constructor(message, options) {
|
|
131
|
-
super(message);
|
|
132
|
-
if (options?.cause !== void 0) {
|
|
133
|
-
this.cause = options.cause;
|
|
134
|
-
}
|
|
133
|
+
super(message, options?.cause ? { cause: options.cause } : void 0);
|
|
135
134
|
this.name = this.constructor.name;
|
|
136
135
|
this.code = options?.code ?? "CONTENT_MANAGEMENT_ERROR";
|
|
137
|
-
if (options?.
|
|
138
|
-
this.
|
|
136
|
+
if (options?.context !== void 0) {
|
|
137
|
+
this.context = options.context;
|
|
139
138
|
}
|
|
139
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
var ValidationError = class extends ContentManagementError {
|
|
@@ -172,9 +172,7 @@ var InternalError = class extends ContentManagementError {
|
|
|
172
172
|
|
|
173
173
|
// src/in-memory-adapter.ts
|
|
174
174
|
var InMemoryContentStorage = class {
|
|
175
|
-
|
|
176
|
-
this.store = /* @__PURE__ */ new Map();
|
|
177
|
-
}
|
|
175
|
+
store = /* @__PURE__ */ new Map();
|
|
178
176
|
async list(filters) {
|
|
179
177
|
let items = Array.from(this.store.values());
|
|
180
178
|
if (filters?.type) {
|
|
@@ -242,10 +240,8 @@ var InMemoryContentStorage = class {
|
|
|
242
240
|
}
|
|
243
241
|
};
|
|
244
242
|
var InMemoryWorkflowStorage = class {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
this.contentTypeMap = /* @__PURE__ */ new Map();
|
|
248
|
-
}
|
|
243
|
+
store = /* @__PURE__ */ new Map();
|
|
244
|
+
contentTypeMap = /* @__PURE__ */ new Map();
|
|
249
245
|
// contentType -> workflowId
|
|
250
246
|
async list() {
|
|
251
247
|
return Array.from(this.store.values());
|
|
@@ -286,9 +282,7 @@ var InMemoryWorkflowStorage = class {
|
|
|
286
282
|
}
|
|
287
283
|
};
|
|
288
284
|
var InMemoryContentTypeStorage = class {
|
|
289
|
-
|
|
290
|
-
this.store = /* @__PURE__ */ new Map();
|
|
291
|
-
}
|
|
285
|
+
store = /* @__PURE__ */ new Map();
|
|
292
286
|
async list() {
|
|
293
287
|
return Array.from(this.store.values());
|
|
294
288
|
}
|
|
@@ -313,9 +307,7 @@ var InMemoryContentTypeStorage = class {
|
|
|
313
307
|
}
|
|
314
308
|
};
|
|
315
309
|
var InMemorySocialPostStorage = class {
|
|
316
|
-
|
|
317
|
-
this.store = /* @__PURE__ */ new Map();
|
|
318
|
-
}
|
|
310
|
+
store = /* @__PURE__ */ new Map();
|
|
319
311
|
async list(filters) {
|
|
320
312
|
let items = Array.from(this.store.values());
|
|
321
313
|
if (filters?.contentId) {
|
|
@@ -353,9 +345,7 @@ var InMemorySocialPostStorage = class {
|
|
|
353
345
|
}
|
|
354
346
|
};
|
|
355
347
|
var InMemoryAIReviewStorage = class {
|
|
356
|
-
|
|
357
|
-
this.store = /* @__PURE__ */ new Map();
|
|
358
|
-
}
|
|
348
|
+
store = /* @__PURE__ */ new Map();
|
|
359
349
|
async list(filters) {
|
|
360
350
|
let items = Array.from(this.store.values());
|
|
361
351
|
if (filters?.contentId) {
|
|
@@ -395,6 +385,10 @@ function createInMemoryAdapter() {
|
|
|
395
385
|
// src/namespaces/content.ts
|
|
396
386
|
import * as crypto from "crypto";
|
|
397
387
|
var ContentNamespaceImpl = class {
|
|
388
|
+
emitter;
|
|
389
|
+
storage;
|
|
390
|
+
getContentTypes;
|
|
391
|
+
getPublishers;
|
|
398
392
|
constructor(emitter, storage, getContentTypes, getPublishers) {
|
|
399
393
|
this.emitter = emitter;
|
|
400
394
|
this.storage = storage;
|
|
@@ -413,7 +407,7 @@ var ContentNamespaceImpl = class {
|
|
|
413
407
|
const result = contentTypes.validate(input.type, dataToValidate);
|
|
414
408
|
if (!result.valid) {
|
|
415
409
|
throw new ValidationError("Content type schema validation failed", {
|
|
416
|
-
|
|
410
|
+
context: { errors: result.errors }
|
|
417
411
|
});
|
|
418
412
|
}
|
|
419
413
|
}
|
|
@@ -484,7 +478,7 @@ var ContentNamespaceImpl = class {
|
|
|
484
478
|
throw new ValidationError(
|
|
485
479
|
`Content is not at a publish-eligible stage. Current stage: "${existing.workflowStage ?? "none"}", required publish stage: "${publishStage.id}"`,
|
|
486
480
|
{
|
|
487
|
-
|
|
481
|
+
context: {
|
|
488
482
|
currentStage: existing.workflowStage ?? null,
|
|
489
483
|
requiredStage: publishStage.id
|
|
490
484
|
}
|
|
@@ -576,9 +570,7 @@ var ContentNamespaceImpl = class {
|
|
|
576
570
|
// src/namespaces/content-types.ts
|
|
577
571
|
import { z as z2 } from "zod";
|
|
578
572
|
var ContentTypesNamespaceImpl = class {
|
|
579
|
-
|
|
580
|
-
this.store = /* @__PURE__ */ new Map();
|
|
581
|
-
}
|
|
573
|
+
store = /* @__PURE__ */ new Map();
|
|
582
574
|
register(definition) {
|
|
583
575
|
if ("schema" in definition && definition.schema) {
|
|
584
576
|
const def = definition;
|
|
@@ -638,8 +630,9 @@ var ContentTypesNamespaceImpl = class {
|
|
|
638
630
|
// src/namespaces/workflows.ts
|
|
639
631
|
import * as crypto2 from "crypto";
|
|
640
632
|
var WorkflowsNamespaceImpl = class {
|
|
633
|
+
cache = /* @__PURE__ */ new Map();
|
|
634
|
+
storage;
|
|
641
635
|
constructor(storage) {
|
|
642
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
643
636
|
this.storage = storage;
|
|
644
637
|
}
|
|
645
638
|
/** Load workflows from storage into cache. Called during suite initialization. */
|
|
@@ -704,7 +697,7 @@ var WorkflowsNamespaceImpl = class {
|
|
|
704
697
|
if (assignedContent.length > 0) {
|
|
705
698
|
throw new ConflictError(
|
|
706
699
|
`Cannot delete workflow "${id}": ${assignedContent.length} content item(s) are assigned to it. Reassign or archive them first.`,
|
|
707
|
-
{
|
|
700
|
+
{ context: { assignedCount: assignedContent.length } }
|
|
708
701
|
);
|
|
709
702
|
}
|
|
710
703
|
await this.storage.workflows.delete(id);
|
|
@@ -716,8 +709,9 @@ var WorkflowsNamespaceImpl = class {
|
|
|
716
709
|
// src/namespaces/users.ts
|
|
717
710
|
import * as crypto3 from "crypto";
|
|
718
711
|
var UsersNamespaceImpl = class {
|
|
712
|
+
store = /* @__PURE__ */ new Map();
|
|
713
|
+
emitter;
|
|
719
714
|
constructor(emitter) {
|
|
720
|
-
this.store = /* @__PURE__ */ new Map();
|
|
721
715
|
this.emitter = emitter;
|
|
722
716
|
}
|
|
723
717
|
async create(input) {
|
|
@@ -766,9 +760,7 @@ var UsersNamespaceImpl = class {
|
|
|
766
760
|
}
|
|
767
761
|
};
|
|
768
762
|
var PermissionsNamespaceImpl = class {
|
|
769
|
-
|
|
770
|
-
this.store = /* @__PURE__ */ new Map();
|
|
771
|
-
}
|
|
763
|
+
store = /* @__PURE__ */ new Map();
|
|
772
764
|
async check(userId, permission) {
|
|
773
765
|
const perms = this.store.get(userId);
|
|
774
766
|
return perms?.has(permission) ?? false;
|
|
@@ -807,6 +799,8 @@ function deepMerge(target, source) {
|
|
|
807
799
|
return result;
|
|
808
800
|
}
|
|
809
801
|
var ConfigNamespaceImpl = class {
|
|
802
|
+
config;
|
|
803
|
+
emitter;
|
|
810
804
|
constructor(initialConfig, emitter) {
|
|
811
805
|
this.config = initialConfig;
|
|
812
806
|
this.emitter = emitter;
|
|
@@ -831,8 +825,9 @@ var ConfigNamespaceImpl = class {
|
|
|
831
825
|
|
|
832
826
|
// src/namespaces/plugins.ts
|
|
833
827
|
var PluginsNamespaceImpl = class {
|
|
828
|
+
store = /* @__PURE__ */ new Map();
|
|
829
|
+
suite;
|
|
834
830
|
constructor(suite) {
|
|
835
|
-
this.store = /* @__PURE__ */ new Map();
|
|
836
831
|
this.suite = suite;
|
|
837
832
|
}
|
|
838
833
|
async register(plugin) {
|
|
@@ -856,11 +851,9 @@ var PluginsNamespaceImpl = class {
|
|
|
856
851
|
|
|
857
852
|
// src/namespaces/publishers.ts
|
|
858
853
|
var WebsitePublisher = class {
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
this.acceptedTypes = ["blog-post", "article", "page", "generic", "text"];
|
|
863
|
-
}
|
|
854
|
+
id = "website";
|
|
855
|
+
name = "Website";
|
|
856
|
+
acceptedTypes = ["blog-post", "article", "page", "generic", "text"];
|
|
864
857
|
async publish(content) {
|
|
865
858
|
const slug = content.title ? content.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") : content.id;
|
|
866
859
|
return {
|
|
@@ -871,11 +864,9 @@ var WebsitePublisher = class {
|
|
|
871
864
|
}
|
|
872
865
|
};
|
|
873
866
|
var RSSPublisher = class {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
this.acceptedTypes = ["blog-post", "article", "rss-article", "generic", "text"];
|
|
878
|
-
}
|
|
867
|
+
id = "rss";
|
|
868
|
+
name = "RSS Feed";
|
|
869
|
+
acceptedTypes = ["blog-post", "article", "rss-article", "generic", "text"];
|
|
879
870
|
async publish(content) {
|
|
880
871
|
return {
|
|
881
872
|
channelId: this.id,
|
|
@@ -885,8 +876,9 @@ var RSSPublisher = class {
|
|
|
885
876
|
}
|
|
886
877
|
};
|
|
887
878
|
var PublishersNamespaceImpl = class {
|
|
879
|
+
store = /* @__PURE__ */ new Map();
|
|
880
|
+
emitter;
|
|
888
881
|
constructor(emitter) {
|
|
889
|
-
this.store = /* @__PURE__ */ new Map();
|
|
890
882
|
this.emitter = emitter;
|
|
891
883
|
this.store.set("website", new WebsitePublisher());
|
|
892
884
|
this.store.set("rss", new RSSPublisher());
|
|
@@ -912,8 +904,11 @@ var PublishersNamespaceImpl = class {
|
|
|
912
904
|
// src/namespaces/sources.ts
|
|
913
905
|
import * as crypto4 from "crypto";
|
|
914
906
|
var SourcesNamespaceImpl = class {
|
|
907
|
+
store = /* @__PURE__ */ new Map();
|
|
908
|
+
emitter;
|
|
909
|
+
storage;
|
|
910
|
+
workflowDefaults;
|
|
915
911
|
constructor(emitter, storage, workflowDefaults) {
|
|
916
|
-
this.store = /* @__PURE__ */ new Map();
|
|
917
912
|
this.emitter = emitter;
|
|
918
913
|
this.storage = storage;
|
|
919
914
|
this.workflowDefaults = workflowDefaults;
|
|
@@ -943,7 +938,7 @@ var SourcesNamespaceImpl = class {
|
|
|
943
938
|
const validationErrors = await source.validate(rawPayload);
|
|
944
939
|
if (validationErrors.length > 0) {
|
|
945
940
|
throw new ValidationError("Source validation failed", {
|
|
946
|
-
|
|
941
|
+
context: { errors: validationErrors }
|
|
947
942
|
});
|
|
948
943
|
}
|
|
949
944
|
}
|
|
@@ -979,6 +974,12 @@ var SourcesNamespaceImpl = class {
|
|
|
979
974
|
// src/namespaces/ai.ts
|
|
980
975
|
import * as crypto5 from "crypto";
|
|
981
976
|
var AINamespaceImpl = class {
|
|
977
|
+
emitter;
|
|
978
|
+
storage;
|
|
979
|
+
reviewService;
|
|
980
|
+
socialGeneratorService;
|
|
981
|
+
enhanceService;
|
|
982
|
+
workflowDefaults;
|
|
982
983
|
constructor(emitter, storage, options) {
|
|
983
984
|
this.emitter = emitter;
|
|
984
985
|
this.storage = storage;
|
|
@@ -1072,8 +1073,10 @@ var AINamespaceImpl = class {
|
|
|
1072
1073
|
|
|
1073
1074
|
// src/namespaces/social.ts
|
|
1074
1075
|
var SocialNamespaceImpl = class {
|
|
1076
|
+
store = /* @__PURE__ */ new Map();
|
|
1077
|
+
emitter;
|
|
1078
|
+
storage;
|
|
1075
1079
|
constructor(emitter, storage) {
|
|
1076
|
-
this.store = /* @__PURE__ */ new Map();
|
|
1077
1080
|
this.emitter = emitter;
|
|
1078
1081
|
this.storage = storage;
|
|
1079
1082
|
}
|
|
@@ -1100,7 +1103,7 @@ var SocialNamespaceImpl = class {
|
|
|
1100
1103
|
if (missing.length > 0) {
|
|
1101
1104
|
throw new ValidationError(
|
|
1102
1105
|
`Unregistered social platform(s): ${missing.join(", ")}`,
|
|
1103
|
-
{
|
|
1106
|
+
{ context: { missingPlatforms: missing } }
|
|
1104
1107
|
);
|
|
1105
1108
|
}
|
|
1106
1109
|
const content = await this.storage.content.get(contentId);
|
|
@@ -1116,7 +1119,7 @@ var SocialNamespaceImpl = class {
|
|
|
1116
1119
|
throw new ValidationError(
|
|
1117
1120
|
`Content is not at a publish-eligible stage. Current stage: "${content.workflowStage ?? "none"}", required publish stage: "${publishStage.id}"`,
|
|
1118
1121
|
{
|
|
1119
|
-
|
|
1122
|
+
context: {
|
|
1120
1123
|
currentStage: content.workflowStage ?? null,
|
|
1121
1124
|
requiredStage: publishStage.id
|
|
1122
1125
|
}
|
|
@@ -1207,9 +1210,23 @@ var SocialNamespaceImpl = class {
|
|
|
1207
1210
|
|
|
1208
1211
|
// src/content-management-suite.ts
|
|
1209
1212
|
var ContentManagementSuiteImpl = class extends EventEmitter {
|
|
1213
|
+
content;
|
|
1214
|
+
contentTypes;
|
|
1215
|
+
workflows;
|
|
1216
|
+
users;
|
|
1217
|
+
permissions;
|
|
1218
|
+
config;
|
|
1219
|
+
plugins;
|
|
1220
|
+
publishers;
|
|
1221
|
+
sources;
|
|
1222
|
+
ai;
|
|
1223
|
+
social;
|
|
1224
|
+
_logger;
|
|
1225
|
+
_options;
|
|
1226
|
+
_storage;
|
|
1227
|
+
_initialized = false;
|
|
1210
1228
|
constructor(options) {
|
|
1211
1229
|
super();
|
|
1212
|
-
this._initialized = false;
|
|
1213
1230
|
this._options = options ?? {};
|
|
1214
1231
|
this._logger = this._options.logger;
|
|
1215
1232
|
this._storage = this._options.storage ?? createInMemoryAdapter();
|