@coursebuilder/adapter-drizzle 2.0.0 → 2.1.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 (77) hide show
  1. package/dist/{chunk-ULJCXOOM.js → chunk-25RKHMRM.js} +521 -4993
  2. package/dist/{chunk-WPDVDHLH.js → chunk-2AW5KYAK.js} +2 -2
  3. package/dist/{chunk-QDWLBCD3.js → chunk-3AF6MZQ7.js} +2 -2
  4. package/dist/{chunk-RDAVEULA.js → chunk-3EF5ZXLG.js} +2 -2
  5. package/dist/{chunk-4SMVVOU5.js → chunk-4SWTV7Z3.js} +2 -2
  6. package/dist/{chunk-6VDGZ4KA.js → chunk-7FBSP3VD.js} +2 -2
  7. package/dist/chunk-AP5HBIV4.js +112 -0
  8. package/dist/chunk-CFSRMUNC.js +78 -0
  9. package/dist/{chunk-Q5NZ5UFZ.js → chunk-DUFH5L2F.js} +2 -2
  10. package/dist/{chunk-DHII2GRW.js → chunk-EZEQQJNH.js} +2 -2
  11. package/dist/chunk-F56AI52P.js +49 -0
  12. package/dist/chunk-FJGNLVE4.js +101 -0
  13. package/dist/chunk-HAQZSRJL.js +4696 -0
  14. package/dist/chunk-I2U5PTWN.js +79 -0
  15. package/dist/chunk-IBQGXFEX.js +8729 -0
  16. package/dist/chunk-KIQLUFJX.js +101 -0
  17. package/dist/{chunk-3XHKEHGF.js → chunk-M3WM5Q7W.js} +2 -2
  18. package/dist/{chunk-52A4W4YI.js → chunk-MYG6PCE3.js} +2 -2
  19. package/dist/chunk-PJORQUQP.js +58 -0
  20. package/dist/{chunk-DB473RZJ.js → chunk-PNPTKVJ4.js} +4 -4
  21. package/dist/chunk-W6RPAAKG.js +2144 -0
  22. package/dist/chunk-WKJTU24D.js +88 -0
  23. package/dist/chunk-WWBSNLRC.js +63 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.js +18 -17
  26. package/dist/lib/mysql/cms-resource-actions.cjs +4715 -0
  27. package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -0
  28. package/dist/lib/mysql/cms-resource-actions.d.cts +140 -0
  29. package/dist/lib/mysql/cms-resource-actions.d.ts +140 -0
  30. package/dist/lib/mysql/cms-resource-actions.js +8 -0
  31. package/dist/lib/mysql/cms-resource-actions.js.map +1 -0
  32. package/dist/lib/mysql/index.cjs +398 -186
  33. package/dist/lib/mysql/index.cjs.map +1 -1
  34. package/dist/lib/mysql/index.d.cts +5 -0
  35. package/dist/lib/mysql/index.d.ts +5 -0
  36. package/dist/lib/mysql/index.js +21 -17
  37. package/dist/lib/mysql/schemas/auth/accounts.js +5 -5
  38. package/dist/lib/mysql/schemas/auth/device-access-token.js +6 -6
  39. package/dist/lib/mysql/schemas/auth/device-verification.js +6 -6
  40. package/dist/lib/mysql/schemas/auth/personal-access-token.js +6 -6
  41. package/dist/lib/mysql/schemas/auth/profiles.js +5 -5
  42. package/dist/lib/mysql/schemas/auth/role-permissions.js +6 -6
  43. package/dist/lib/mysql/schemas/auth/roles.js +5 -5
  44. package/dist/lib/mysql/schemas/auth/sessions.js +6 -6
  45. package/dist/lib/mysql/schemas/auth/user-permissions.js +5 -5
  46. package/dist/lib/mysql/schemas/auth/user-prefs.js +5 -5
  47. package/dist/lib/mysql/schemas/auth/user-roles.js +5 -5
  48. package/dist/lib/mysql/schemas/auth/users.js +5 -5
  49. package/dist/lib/mysql/schemas/commerce/coupon.js +5 -5
  50. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +5 -5
  51. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +5 -5
  52. package/dist/lib/mysql/schemas/commerce/price.js +5 -5
  53. package/dist/lib/mysql/schemas/commerce/product.js +5 -5
  54. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +6 -6
  55. package/dist/lib/mysql/schemas/commerce/purchase.js +5 -5
  56. package/dist/lib/mysql/schemas/commerce/subscription.js +5 -5
  57. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +6 -6
  58. package/dist/lib/mysql/schemas/communication/comment.js +5 -5
  59. package/dist/lib/mysql/schemas/communication/communication-preferences.js +5 -5
  60. package/dist/lib/mysql/schemas/communication/question-response.js +6 -6
  61. package/dist/lib/mysql/schemas/content/content-contributions.js +5 -5
  62. package/dist/lib/mysql/schemas/content/content-resource-product.js +5 -5
  63. package/dist/lib/mysql/schemas/content/content-resource-resource.js +5 -5
  64. package/dist/lib/mysql/schemas/content/content-resource-tag.js +5 -5
  65. package/dist/lib/mysql/schemas/content/content-resource-version.js +5 -5
  66. package/dist/lib/mysql/schemas/content/content-resource.js +5 -5
  67. package/dist/lib/mysql/schemas/content/tag-tag.js +5 -5
  68. package/dist/lib/mysql/schemas/content/tag.js +5 -5
  69. package/dist/lib/mysql/schemas/entitlements/entitlement.js +6 -6
  70. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +5 -5
  71. package/dist/lib/mysql/schemas/org/organization-memberships.js +5 -5
  72. package/dist/lib/mysql/schemas/org/organizations.js +5 -5
  73. package/dist/lib/utils.d.cts +5 -0
  74. package/dist/lib/utils.d.ts +5 -0
  75. package/package.json +2 -2
  76. package/src/lib/mysql/cms-resource-actions.ts +490 -0
  77. package/src/lib/mysql/index.ts +2 -0
@@ -0,0 +1,140 @@
1
+ import { MySqlDatabase } from 'drizzle-orm/mysql-core';
2
+ import { z } from 'zod';
3
+ import { getContentResourceProductSchema } from './schemas/content/content-resource-product.cjs';
4
+ import { getContentResourceResourceSchema } from './schemas/content/content-resource-resource.cjs';
5
+ import { getContentResourceSchema } from './schemas/content/content-resource.cjs';
6
+ import 'drizzle-orm';
7
+ import './schemas/auth/users.cjs';
8
+
9
+ /**
10
+ * Shared CMS-editor query implementations (ai-hero `resources-query.ts`
11
+ * lineage) behind every app's `src/lib/cms/resource-actions.ts` server-action
12
+ * module: the ONE recent-first picker query powering every add-surface, the
13
+ * video-library picker, the post → list membership seed, and the reverse
14
+ * parent lookup behind the "Part of" strip.
15
+ *
16
+ * This is a FACTORY, not a server-action module: `'use server'` exports must
17
+ * live in each app (they bind to the app bundle), so apps instantiate this
18
+ * with their db/auth and re-export thin `'use server'` wrappers with
19
+ * identical signatures.
20
+ */
21
+ type ContentResourceTable = ReturnType<typeof getContentResourceSchema>;
22
+ type ContentResourceResourceTable = ReturnType<typeof getContentResourceResourceSchema>;
23
+ type ContentResourceProductTable = ReturnType<typeof getContentResourceProductSchema>;
24
+ /** Minimal session+ability surface the actions gate on. */
25
+ interface CmsAuthContext {
26
+ session: {
27
+ user?: unknown | null;
28
+ } | null;
29
+ ability: {
30
+ can: (action: any, subject: any) => boolean;
31
+ };
32
+ }
33
+ /** Row shape for the ResourcePicker (mirrors `PickerItem` in the ui kit). */
34
+ interface CmsPickerItem {
35
+ id: string;
36
+ type: string;
37
+ title: string;
38
+ slug?: string;
39
+ state?: string;
40
+ updatedAt?: string | Date;
41
+ detail?: string;
42
+ thumbnailUrl?: string;
43
+ }
44
+ /** Row shape for the "Part of" strip (mirrors `ResourceParent` in the ui kit). */
45
+ interface CmsResourceParent {
46
+ id: string;
47
+ type: string;
48
+ title: string;
49
+ href: string;
50
+ detail?: string;
51
+ }
52
+ /** Row shape for the post editor's lists field (mirrors `ListMembership`). */
53
+ interface CmsListMembership {
54
+ listId: string;
55
+ title: string;
56
+ slug?: string;
57
+ href?: string;
58
+ position: number;
59
+ }
60
+ /** Lean video-library row for the body editor's "Video…" picker. */
61
+ interface VideoPickerRow {
62
+ id: string;
63
+ title: string;
64
+ state: string;
65
+ thumbnailUrl?: string;
66
+ duration: number | null;
67
+ createdAt: Date | null;
68
+ }
69
+ /** Row shape for the Media tab's image grid (mirrors `ImageLibraryRow` in the ui kit, plus `id`). */
70
+ declare const CmsImageResourceRowSchema: z.ZodObject<{
71
+ id: z.ZodString;
72
+ url: z.ZodString;
73
+ alt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
74
+ createdAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ id: string;
77
+ url: string;
78
+ createdAt?: Date | null | undefined;
79
+ alt?: string | null | undefined;
80
+ }, {
81
+ id: string;
82
+ url: string;
83
+ createdAt?: Date | null | undefined;
84
+ alt?: string | null | undefined;
85
+ }>;
86
+ type CmsImageResourceRow = z.infer<typeof CmsImageResourceRowSchema>;
87
+ declare const ListResourcesForPickerInputSchema: z.ZodObject<{
88
+ types: z.ZodArray<z.ZodString, "many">;
89
+ search: z.ZodOptional<z.ZodString>;
90
+ excludeIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
91
+ limit: z.ZodDefault<z.ZodNumber>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ limit: number;
94
+ types: string[];
95
+ excludeIds: string[];
96
+ search?: string | undefined;
97
+ }, {
98
+ types: string[];
99
+ limit?: number | undefined;
100
+ search?: string | undefined;
101
+ excludeIds?: string[] | undefined;
102
+ }>;
103
+ type ListResourcesForPickerInput = z.input<typeof ListResourcesForPickerInputSchema>;
104
+ interface CreateCmsResourceActionsOptions {
105
+ /**
106
+ * The app's drizzle client. Loosely typed on purpose — each app's client
107
+ * carries its own full-schema generic, but the relational keys used here
108
+ * (`contentResourceResource`, `contentResourceProduct`) are guaranteed by
109
+ * `getCourseBuilderSchema`.
110
+ */
111
+ db: InstanceType<typeof MySqlDatabase>;
112
+ contentResource: ContentResourceTable;
113
+ contentResourceResource: ContentResourceResourceTable;
114
+ contentResourceProduct: ContentResourceProductTable;
115
+ /** The app's session+ability getter (e.g. `getServerAuthSession`). */
116
+ getAuthContext: () => Promise<CmsAuthContext>;
117
+ /**
118
+ * App route registry for parent edit links — apps with the shared
119
+ * resource-paths registry pass `(type, slug) => getResourcePath(type,
120
+ * slug, 'edit')`; apps without one pass their own switch.
121
+ */
122
+ getEditHref: (type: string, slug: string) => string;
123
+ }
124
+ declare function createCmsResourceActions(options: CreateCmsResourceActionsOptions): {
125
+ listResourcesForPicker: (input: ListResourcesForPickerInput) => Promise<CmsPickerItem[]>;
126
+ listVideoResourcesForPicker: (input: {
127
+ search?: string;
128
+ excludeIds?: string[];
129
+ limit?: number;
130
+ offset?: number;
131
+ }) => Promise<VideoPickerRow[]>;
132
+ listImageResources: ({ limit, offset, }: {
133
+ limit: number;
134
+ offset?: number;
135
+ }) => Promise<CmsImageResourceRow[]>;
136
+ getPostListMemberships: (postId: string) => Promise<CmsListMembership[]>;
137
+ getResourceParents: (resourceId: string) => Promise<CmsResourceParent[]>;
138
+ };
139
+
140
+ export { type CmsAuthContext, type CmsImageResourceRow, type CmsListMembership, type CmsPickerItem, type CmsResourceParent, type CreateCmsResourceActionsOptions, type ListResourcesForPickerInput, type VideoPickerRow, createCmsResourceActions };
@@ -0,0 +1,140 @@
1
+ import { MySqlDatabase } from 'drizzle-orm/mysql-core';
2
+ import { z } from 'zod';
3
+ import { getContentResourceProductSchema } from './schemas/content/content-resource-product.js';
4
+ import { getContentResourceResourceSchema } from './schemas/content/content-resource-resource.js';
5
+ import { getContentResourceSchema } from './schemas/content/content-resource.js';
6
+ import 'drizzle-orm';
7
+ import './schemas/auth/users.js';
8
+
9
+ /**
10
+ * Shared CMS-editor query implementations (ai-hero `resources-query.ts`
11
+ * lineage) behind every app's `src/lib/cms/resource-actions.ts` server-action
12
+ * module: the ONE recent-first picker query powering every add-surface, the
13
+ * video-library picker, the post → list membership seed, and the reverse
14
+ * parent lookup behind the "Part of" strip.
15
+ *
16
+ * This is a FACTORY, not a server-action module: `'use server'` exports must
17
+ * live in each app (they bind to the app bundle), so apps instantiate this
18
+ * with their db/auth and re-export thin `'use server'` wrappers with
19
+ * identical signatures.
20
+ */
21
+ type ContentResourceTable = ReturnType<typeof getContentResourceSchema>;
22
+ type ContentResourceResourceTable = ReturnType<typeof getContentResourceResourceSchema>;
23
+ type ContentResourceProductTable = ReturnType<typeof getContentResourceProductSchema>;
24
+ /** Minimal session+ability surface the actions gate on. */
25
+ interface CmsAuthContext {
26
+ session: {
27
+ user?: unknown | null;
28
+ } | null;
29
+ ability: {
30
+ can: (action: any, subject: any) => boolean;
31
+ };
32
+ }
33
+ /** Row shape for the ResourcePicker (mirrors `PickerItem` in the ui kit). */
34
+ interface CmsPickerItem {
35
+ id: string;
36
+ type: string;
37
+ title: string;
38
+ slug?: string;
39
+ state?: string;
40
+ updatedAt?: string | Date;
41
+ detail?: string;
42
+ thumbnailUrl?: string;
43
+ }
44
+ /** Row shape for the "Part of" strip (mirrors `ResourceParent` in the ui kit). */
45
+ interface CmsResourceParent {
46
+ id: string;
47
+ type: string;
48
+ title: string;
49
+ href: string;
50
+ detail?: string;
51
+ }
52
+ /** Row shape for the post editor's lists field (mirrors `ListMembership`). */
53
+ interface CmsListMembership {
54
+ listId: string;
55
+ title: string;
56
+ slug?: string;
57
+ href?: string;
58
+ position: number;
59
+ }
60
+ /** Lean video-library row for the body editor's "Video…" picker. */
61
+ interface VideoPickerRow {
62
+ id: string;
63
+ title: string;
64
+ state: string;
65
+ thumbnailUrl?: string;
66
+ duration: number | null;
67
+ createdAt: Date | null;
68
+ }
69
+ /** Row shape for the Media tab's image grid (mirrors `ImageLibraryRow` in the ui kit, plus `id`). */
70
+ declare const CmsImageResourceRowSchema: z.ZodObject<{
71
+ id: z.ZodString;
72
+ url: z.ZodString;
73
+ alt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
74
+ createdAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
75
+ }, "strip", z.ZodTypeAny, {
76
+ id: string;
77
+ url: string;
78
+ createdAt?: Date | null | undefined;
79
+ alt?: string | null | undefined;
80
+ }, {
81
+ id: string;
82
+ url: string;
83
+ createdAt?: Date | null | undefined;
84
+ alt?: string | null | undefined;
85
+ }>;
86
+ type CmsImageResourceRow = z.infer<typeof CmsImageResourceRowSchema>;
87
+ declare const ListResourcesForPickerInputSchema: z.ZodObject<{
88
+ types: z.ZodArray<z.ZodString, "many">;
89
+ search: z.ZodOptional<z.ZodString>;
90
+ excludeIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
91
+ limit: z.ZodDefault<z.ZodNumber>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ limit: number;
94
+ types: string[];
95
+ excludeIds: string[];
96
+ search?: string | undefined;
97
+ }, {
98
+ types: string[];
99
+ limit?: number | undefined;
100
+ search?: string | undefined;
101
+ excludeIds?: string[] | undefined;
102
+ }>;
103
+ type ListResourcesForPickerInput = z.input<typeof ListResourcesForPickerInputSchema>;
104
+ interface CreateCmsResourceActionsOptions {
105
+ /**
106
+ * The app's drizzle client. Loosely typed on purpose — each app's client
107
+ * carries its own full-schema generic, but the relational keys used here
108
+ * (`contentResourceResource`, `contentResourceProduct`) are guaranteed by
109
+ * `getCourseBuilderSchema`.
110
+ */
111
+ db: InstanceType<typeof MySqlDatabase>;
112
+ contentResource: ContentResourceTable;
113
+ contentResourceResource: ContentResourceResourceTable;
114
+ contentResourceProduct: ContentResourceProductTable;
115
+ /** The app's session+ability getter (e.g. `getServerAuthSession`). */
116
+ getAuthContext: () => Promise<CmsAuthContext>;
117
+ /**
118
+ * App route registry for parent edit links — apps with the shared
119
+ * resource-paths registry pass `(type, slug) => getResourcePath(type,
120
+ * slug, 'edit')`; apps without one pass their own switch.
121
+ */
122
+ getEditHref: (type: string, slug: string) => string;
123
+ }
124
+ declare function createCmsResourceActions(options: CreateCmsResourceActionsOptions): {
125
+ listResourcesForPicker: (input: ListResourcesForPickerInput) => Promise<CmsPickerItem[]>;
126
+ listVideoResourcesForPicker: (input: {
127
+ search?: string;
128
+ excludeIds?: string[];
129
+ limit?: number;
130
+ offset?: number;
131
+ }) => Promise<VideoPickerRow[]>;
132
+ listImageResources: ({ limit, offset, }: {
133
+ limit: number;
134
+ offset?: number;
135
+ }) => Promise<CmsImageResourceRow[]>;
136
+ getPostListMemberships: (postId: string) => Promise<CmsListMembership[]>;
137
+ getResourceParents: (resourceId: string) => Promise<CmsResourceParent[]>;
138
+ };
139
+
140
+ export { type CmsAuthContext, type CmsImageResourceRow, type CmsListMembership, type CmsPickerItem, type CmsResourceParent, type CreateCmsResourceActionsOptions, type ListResourcesForPickerInput, type VideoPickerRow, createCmsResourceActions };
@@ -0,0 +1,8 @@
1
+ import {
2
+ createCmsResourceActions
3
+ } from "../../chunk-HAQZSRJL.js";
4
+ import "../../chunk-2X5XVNDN.js";
5
+ export {
6
+ createCmsResourceActions
7
+ };
8
+ //# sourceMappingURL=cms-resource-actions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}