@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.
- package/dist/{chunk-ULJCXOOM.js → chunk-25RKHMRM.js} +521 -4993
- package/dist/{chunk-WPDVDHLH.js → chunk-2AW5KYAK.js} +2 -2
- package/dist/{chunk-QDWLBCD3.js → chunk-3AF6MZQ7.js} +2 -2
- package/dist/{chunk-RDAVEULA.js → chunk-3EF5ZXLG.js} +2 -2
- package/dist/{chunk-4SMVVOU5.js → chunk-4SWTV7Z3.js} +2 -2
- package/dist/{chunk-6VDGZ4KA.js → chunk-7FBSP3VD.js} +2 -2
- package/dist/chunk-AP5HBIV4.js +112 -0
- package/dist/chunk-CFSRMUNC.js +78 -0
- package/dist/{chunk-Q5NZ5UFZ.js → chunk-DUFH5L2F.js} +2 -2
- package/dist/{chunk-DHII2GRW.js → chunk-EZEQQJNH.js} +2 -2
- package/dist/chunk-F56AI52P.js +49 -0
- package/dist/chunk-FJGNLVE4.js +101 -0
- package/dist/chunk-HAQZSRJL.js +4696 -0
- package/dist/chunk-I2U5PTWN.js +79 -0
- package/dist/chunk-IBQGXFEX.js +8729 -0
- package/dist/chunk-KIQLUFJX.js +101 -0
- package/dist/{chunk-3XHKEHGF.js → chunk-M3WM5Q7W.js} +2 -2
- package/dist/{chunk-52A4W4YI.js → chunk-MYG6PCE3.js} +2 -2
- package/dist/chunk-PJORQUQP.js +58 -0
- package/dist/{chunk-DB473RZJ.js → chunk-PNPTKVJ4.js} +4 -4
- package/dist/chunk-W6RPAAKG.js +2144 -0
- package/dist/chunk-WKJTU24D.js +88 -0
- package/dist/chunk-WWBSNLRC.js +63 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +18 -17
- package/dist/lib/mysql/cms-resource-actions.cjs +4715 -0
- package/dist/lib/mysql/cms-resource-actions.cjs.map +1 -0
- package/dist/lib/mysql/cms-resource-actions.d.cts +140 -0
- package/dist/lib/mysql/cms-resource-actions.d.ts +140 -0
- package/dist/lib/mysql/cms-resource-actions.js +8 -0
- package/dist/lib/mysql/cms-resource-actions.js.map +1 -0
- package/dist/lib/mysql/index.cjs +398 -186
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.d.cts +5 -0
- package/dist/lib/mysql/index.d.ts +5 -0
- package/dist/lib/mysql/index.js +21 -17
- package/dist/lib/mysql/schemas/auth/accounts.js +5 -5
- package/dist/lib/mysql/schemas/auth/device-access-token.js +6 -6
- package/dist/lib/mysql/schemas/auth/device-verification.js +6 -6
- package/dist/lib/mysql/schemas/auth/personal-access-token.js +6 -6
- package/dist/lib/mysql/schemas/auth/profiles.js +5 -5
- package/dist/lib/mysql/schemas/auth/role-permissions.js +6 -6
- package/dist/lib/mysql/schemas/auth/roles.js +5 -5
- package/dist/lib/mysql/schemas/auth/sessions.js +6 -6
- package/dist/lib/mysql/schemas/auth/user-permissions.js +5 -5
- package/dist/lib/mysql/schemas/auth/user-prefs.js +5 -5
- package/dist/lib/mysql/schemas/auth/user-roles.js +5 -5
- package/dist/lib/mysql/schemas/auth/users.js +5 -5
- package/dist/lib/mysql/schemas/commerce/coupon.js +5 -5
- package/dist/lib/mysql/schemas/commerce/merchant-charge.js +5 -5
- package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +5 -5
- package/dist/lib/mysql/schemas/commerce/price.js +5 -5
- package/dist/lib/mysql/schemas/commerce/product.js +5 -5
- package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +6 -6
- package/dist/lib/mysql/schemas/commerce/purchase.js +5 -5
- package/dist/lib/mysql/schemas/commerce/subscription.js +5 -5
- package/dist/lib/mysql/schemas/commerce/upgradable-products.js +6 -6
- package/dist/lib/mysql/schemas/communication/comment.js +5 -5
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +5 -5
- package/dist/lib/mysql/schemas/communication/question-response.js +6 -6
- package/dist/lib/mysql/schemas/content/content-contributions.js +5 -5
- package/dist/lib/mysql/schemas/content/content-resource-product.js +5 -5
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +5 -5
- package/dist/lib/mysql/schemas/content/content-resource-tag.js +5 -5
- package/dist/lib/mysql/schemas/content/content-resource-version.js +5 -5
- package/dist/lib/mysql/schemas/content/content-resource.js +5 -5
- package/dist/lib/mysql/schemas/content/tag-tag.js +5 -5
- package/dist/lib/mysql/schemas/content/tag.js +5 -5
- package/dist/lib/mysql/schemas/entitlements/entitlement.js +6 -6
- package/dist/lib/mysql/schemas/org/organization-membership-roles.js +5 -5
- package/dist/lib/mysql/schemas/org/organization-memberships.js +5 -5
- package/dist/lib/mysql/schemas/org/organizations.js +5 -5
- package/dist/lib/utils.d.cts +5 -0
- package/dist/lib/utils.d.ts +5 -0
- package/package.json +2 -2
- package/src/lib/mysql/cms-resource-actions.ts +490 -0
- 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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|