@nexpress/core 0.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 (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/dist/audit-54XLVCWD.js +14 -0
  4. package/dist/audit-54XLVCWD.js.map +1 -0
  5. package/dist/auth.d.ts +640 -0
  6. package/dist/auth.js +94 -0
  7. package/dist/auth.js.map +1 -0
  8. package/dist/can-YLUHRJAB.js +19 -0
  9. package/dist/can-YLUHRJAB.js.map +1 -0
  10. package/dist/chunk-2G264RCD.js +68 -0
  11. package/dist/chunk-2G264RCD.js.map +1 -0
  12. package/dist/chunk-2YDGE7YX.js +92 -0
  13. package/dist/chunk-2YDGE7YX.js.map +1 -0
  14. package/dist/chunk-473S4TER.js +538 -0
  15. package/dist/chunk-473S4TER.js.map +1 -0
  16. package/dist/chunk-4ZLMEKFX.js +18 -0
  17. package/dist/chunk-4ZLMEKFX.js.map +1 -0
  18. package/dist/chunk-55FU6WED.js +179 -0
  19. package/dist/chunk-55FU6WED.js.map +1 -0
  20. package/dist/chunk-6YI5K2TI.js +1959 -0
  21. package/dist/chunk-6YI5K2TI.js.map +1 -0
  22. package/dist/chunk-BHK3AD3Q.js +41 -0
  23. package/dist/chunk-BHK3AD3Q.js.map +1 -0
  24. package/dist/chunk-CRUQBZUF.js +39 -0
  25. package/dist/chunk-CRUQBZUF.js.map +1 -0
  26. package/dist/chunk-CTSQ7BRI.js +175 -0
  27. package/dist/chunk-CTSQ7BRI.js.map +1 -0
  28. package/dist/chunk-DK2JBJH7.js +81 -0
  29. package/dist/chunk-DK2JBJH7.js.map +1 -0
  30. package/dist/chunk-DP2PREDU.js +597 -0
  31. package/dist/chunk-DP2PREDU.js.map +1 -0
  32. package/dist/chunk-EQ2Z3KMD.js +24 -0
  33. package/dist/chunk-EQ2Z3KMD.js.map +1 -0
  34. package/dist/chunk-FZ7O6DWI.js +305 -0
  35. package/dist/chunk-FZ7O6DWI.js.map +1 -0
  36. package/dist/chunk-ISLYFQWL.js +1270 -0
  37. package/dist/chunk-ISLYFQWL.js.map +1 -0
  38. package/dist/chunk-JJL74ZPK.js +68 -0
  39. package/dist/chunk-JJL74ZPK.js.map +1 -0
  40. package/dist/chunk-JKXAPSU4.js +24 -0
  41. package/dist/chunk-JKXAPSU4.js.map +1 -0
  42. package/dist/chunk-KU5M27ZC.js +24 -0
  43. package/dist/chunk-KU5M27ZC.js.map +1 -0
  44. package/dist/chunk-LSHHRDVR.js +34 -0
  45. package/dist/chunk-LSHHRDVR.js.map +1 -0
  46. package/dist/chunk-M43PGOQY.js +715 -0
  47. package/dist/chunk-M43PGOQY.js.map +1 -0
  48. package/dist/chunk-MEJAHXIO.js +150 -0
  49. package/dist/chunk-MEJAHXIO.js.map +1 -0
  50. package/dist/chunk-NUCGHWCF.js +101 -0
  51. package/dist/chunk-NUCGHWCF.js.map +1 -0
  52. package/dist/chunk-OK5HOCQI.js +845 -0
  53. package/dist/chunk-OK5HOCQI.js.map +1 -0
  54. package/dist/chunk-OROPGO65.js +13 -0
  55. package/dist/chunk-OROPGO65.js.map +1 -0
  56. package/dist/chunk-PPAS4SZR.js +176 -0
  57. package/dist/chunk-PPAS4SZR.js.map +1 -0
  58. package/dist/chunk-PPBWRKO2.js +171 -0
  59. package/dist/chunk-PPBWRKO2.js.map +1 -0
  60. package/dist/chunk-PZ5AY32C.js +10 -0
  61. package/dist/chunk-PZ5AY32C.js.map +1 -0
  62. package/dist/chunk-QO7LAQZH.js +321 -0
  63. package/dist/chunk-QO7LAQZH.js.map +1 -0
  64. package/dist/chunk-QVJ2HCAX.js +225 -0
  65. package/dist/chunk-QVJ2HCAX.js.map +1 -0
  66. package/dist/chunk-RIPHIRPP.js +68 -0
  67. package/dist/chunk-RIPHIRPP.js.map +1 -0
  68. package/dist/chunk-S27S42QY.js +134 -0
  69. package/dist/chunk-S27S42QY.js.map +1 -0
  70. package/dist/chunk-SBCVAC2Z.js +40 -0
  71. package/dist/chunk-SBCVAC2Z.js.map +1 -0
  72. package/dist/chunk-TFJ4MKPH.js +694 -0
  73. package/dist/chunk-TFJ4MKPH.js.map +1 -0
  74. package/dist/chunk-THX3SHYA.js +75 -0
  75. package/dist/chunk-THX3SHYA.js.map +1 -0
  76. package/dist/chunk-UGQSQO5B.js +222 -0
  77. package/dist/chunk-UGQSQO5B.js.map +1 -0
  78. package/dist/chunk-V2UNHGAP.js +26 -0
  79. package/dist/chunk-V2UNHGAP.js.map +1 -0
  80. package/dist/chunk-VGTPQXNQ.js +2790 -0
  81. package/dist/chunk-VGTPQXNQ.js.map +1 -0
  82. package/dist/chunk-VNIHXQ7W.js +194 -0
  83. package/dist/chunk-VNIHXQ7W.js.map +1 -0
  84. package/dist/chunk-WV272MPW.js +31 -0
  85. package/dist/chunk-WV272MPW.js.map +1 -0
  86. package/dist/chunk-X5KKBOUS.js +26 -0
  87. package/dist/chunk-X5KKBOUS.js.map +1 -0
  88. package/dist/chunk-XANPEOJC.js +17 -0
  89. package/dist/chunk-XANPEOJC.js.map +1 -0
  90. package/dist/chunk-XPVQIHAQ.js +83 -0
  91. package/dist/chunk-XPVQIHAQ.js.map +1 -0
  92. package/dist/chunk-ZCINJSS4.js +75 -0
  93. package/dist/chunk-ZCINJSS4.js.map +1 -0
  94. package/dist/community.d.ts +1425 -0
  95. package/dist/community.js +206 -0
  96. package/dist/community.js.map +1 -0
  97. package/dist/config-2GDU7PCK.js +32 -0
  98. package/dist/config-2GDU7PCK.js.map +1 -0
  99. package/dist/context-MNZ4QXPC.js +16 -0
  100. package/dist/context-MNZ4QXPC.js.map +1 -0
  101. package/dist/db-schema.d.ts +4 -0
  102. package/dist/db-schema.js +102 -0
  103. package/dist/db-schema.js.map +1 -0
  104. package/dist/db.d.ts +7 -0
  105. package/dist/db.js +117 -0
  106. package/dist/db.js.map +1 -0
  107. package/dist/digest-SY42GQSU.js +17 -0
  108. package/dist/digest-SY42GQSU.js.map +1 -0
  109. package/dist/errors-5OS3S2J3.js +22 -0
  110. package/dist/errors-5OS3S2J3.js.map +1 -0
  111. package/dist/host-OBOI4MJK.js +51 -0
  112. package/dist/host-OBOI4MJK.js.map +1 -0
  113. package/dist/i18n.d.ts +301 -0
  114. package/dist/i18n.js +68 -0
  115. package/dist/i18n.js.map +1 -0
  116. package/dist/index-B6-_vr_m.d.ts +590 -0
  117. package/dist/index-CY55LC0u.d.ts +4722 -0
  118. package/dist/index-CeiTvwbp.d.ts +168 -0
  119. package/dist/index-XwP1ET8b.d.ts +61 -0
  120. package/dist/index.d.ts +2037 -0
  121. package/dist/index.js +2205 -0
  122. package/dist/index.js.map +1 -0
  123. package/dist/job-log-VZXWQUDK.js +24 -0
  124. package/dist/job-log-VZXWQUDK.js.map +1 -0
  125. package/dist/jobs.d.ts +4 -0
  126. package/dist/jobs.js +76 -0
  127. package/dist/jobs.js.map +1 -0
  128. package/dist/logger-DqGaOU_j.d.ts +29 -0
  129. package/dist/logger-S7REWDNE.js +16 -0
  130. package/dist/logger-S7REWDNE.js.map +1 -0
  131. package/dist/media.d.ts +5 -0
  132. package/dist/media.js +41 -0
  133. package/dist/media.js.map +1 -0
  134. package/dist/mentions-2IHFVSHW.js +23 -0
  135. package/dist/mentions-2IHFVSHW.js.map +1 -0
  136. package/dist/mutes-EWAE5FZR.js +21 -0
  137. package/dist/mutes-EWAE5FZR.js.map +1 -0
  138. package/dist/notification-prefs-VPJDU7I6.js +21 -0
  139. package/dist/notification-prefs-VPJDU7I6.js.map +1 -0
  140. package/dist/observability.d.ts +156 -0
  141. package/dist/observability.js +32 -0
  142. package/dist/observability.js.map +1 -0
  143. package/dist/profanity-adapter-NU2JQSLX.js +12 -0
  144. package/dist/profanity-adapter-NU2JQSLX.js.map +1 -0
  145. package/dist/queue-XE5BC75T.js +14 -0
  146. package/dist/queue-XE5BC75T.js.map +1 -0
  147. package/dist/rate-limit.d.ts +99 -0
  148. package/dist/rate-limit.js +14 -0
  149. package/dist/rate-limit.js.map +1 -0
  150. package/dist/registry-XIXDEPVI.js +31 -0
  151. package/dist/registry-XIXDEPVI.js.map +1 -0
  152. package/dist/reputation-JRL2YQHM.js +11 -0
  153. package/dist/reputation-JRL2YQHM.js.map +1 -0
  154. package/dist/routes.d.ts +43 -0
  155. package/dist/routes.js +12 -0
  156. package/dist/routes.js.map +1 -0
  157. package/dist/scheduled-CIQM57HT.js +20 -0
  158. package/dist/scheduled-CIQM57HT.js.map +1 -0
  159. package/dist/seo.d.ts +410 -0
  160. package/dist/seo.js +44 -0
  161. package/dist/seo.js.map +1 -0
  162. package/dist/settings-FOBIESPB.js +17 -0
  163. package/dist/settings-FOBIESPB.js.map +1 -0
  164. package/dist/spam-adapter-XX3G737Z.js +12 -0
  165. package/dist/spam-adapter-XX3G737Z.js.map +1 -0
  166. package/dist/strings-VAE47B2C.js +29 -0
  167. package/dist/strings-VAE47B2C.js.map +1 -0
  168. package/dist/templates-IFVJMCJ6.js +12 -0
  169. package/dist/templates-IFVJMCJ6.js.map +1 -0
  170. package/dist/types-TlsbXS0T.d.ts +871 -0
  171. package/package.json +129 -0
@@ -0,0 +1,168 @@
1
+ import { i as NpFindResult, H as NpImageSize, j as NpFieldConfig } from './types-TlsbXS0T.js';
2
+ import { and } from 'drizzle-orm';
3
+ import { PgTable } from 'drizzle-orm/pg-core';
4
+ import { ReadableStream } from 'node:stream/web';
5
+
6
+ interface NpFileMetadata {
7
+ contentType: string;
8
+ contentLength: number;
9
+ originalFilename: string;
10
+ }
11
+ interface NpStorageAdapter {
12
+ upload(key: string, data: Buffer | ReadableStream, metadata: NpFileMetadata): Promise<void>;
13
+ getStream(key: string): Promise<ReadableStream>;
14
+ getUrl(key: string): Promise<string>;
15
+ delete(key: string): Promise<void>;
16
+ exists(key: string): Promise<boolean>;
17
+ }
18
+
19
+ declare function setStorageAdapter(adapter: NpStorageAdapter): void;
20
+ declare function getStorageAdapter(): NpStorageAdapter;
21
+ /**
22
+ * Polymorphic uploader: a row on `np_media` is owned by exactly
23
+ * one of staff (`uploadedBy` → `np_users.id`) or member
24
+ * (`uploadedByMemberId` → `np_members.id`, Phase 9.7j). Pass a
25
+ * `null` value as the second argument to `uploadMedia` for plugin /
26
+ * system uploads with no human owner — both columns stay null and
27
+ * the audit log carries the actor.
28
+ */
29
+ type NpMediaUploader = {
30
+ kind: "staff";
31
+ userId: string;
32
+ } | {
33
+ kind: "member";
34
+ memberId: string;
35
+ } | null;
36
+ declare function uploadMedia(file: {
37
+ buffer: Buffer;
38
+ originalFilename: string;
39
+ mimeType: string;
40
+ }, uploader: NpMediaUploader | string, folderId?: string): Promise<{
41
+ id: string;
42
+ status: string;
43
+ }>;
44
+ declare function processMediaImage(mediaId: string, config: {
45
+ sizes?: NpImageSize[];
46
+ format?: string;
47
+ quality?: number;
48
+ }): Promise<void>;
49
+ declare function getMediaById(id: string): Promise<Record<string, unknown> | null>;
50
+ declare function deleteMedia(id: string): Promise<{
51
+ deleted: boolean;
52
+ references?: unknown[];
53
+ }>;
54
+ /**
55
+ * Phase 9.7k uploader filters. `uploaderKind` partitions the
56
+ * library into staff-uploaded rows (`uploaded_by IS NOT NULL`) vs
57
+ * member-uploaded rows (`uploaded_by_member_id IS NOT NULL`) — the
58
+ * two columns are mutually exclusive on every row written through
59
+ * `uploadMedia`. `uploadedByMemberId` narrows to a specific member
60
+ * for "show me everything @handle uploaded" investigations after a
61
+ * spam wave.
62
+ */
63
+ type NpMediaUploaderKindFilter = "staff" | "member";
64
+ declare function listMedia(options: {
65
+ page?: number;
66
+ limit?: number;
67
+ folderId?: string;
68
+ mimeType?: string;
69
+ uploaderKind?: NpMediaUploaderKindFilter;
70
+ uploadedByMemberId?: string;
71
+ /**
72
+ * Substring match against `filename` and `alt`. Matches
73
+ * server-side via `ILIKE`, so the page-builder block-image
74
+ * picker can search the whole library without paging through
75
+ * every result client-side. Empty / whitespace-only `q` is
76
+ * treated as no filter.
77
+ */
78
+ q?: string;
79
+ }): Promise<NpFindResult>;
80
+ declare function cleanupDeletedMedia(olderThanDays: number): Promise<number>;
81
+
82
+ interface NpProcessedImageVariant {
83
+ name: string;
84
+ buffer: Buffer;
85
+ width: number;
86
+ height: number;
87
+ size: number;
88
+ }
89
+ interface NpProcessedImageSourceMetadata {
90
+ width: number | null;
91
+ height: number | null;
92
+ format: string | null;
93
+ }
94
+ interface NpProcessedImageResult {
95
+ source: NpProcessedImageSourceMetadata;
96
+ variants: NpProcessedImageVariant[];
97
+ }
98
+ declare const DEFAULT_IMAGE_SIZES: NpImageSize[];
99
+ declare function processImage(inputBuffer: Buffer, sizes: NpImageSize[], options?: {
100
+ format?: string;
101
+ quality?: number;
102
+ }): Promise<NpProcessedImageResult>;
103
+
104
+ interface InsertValuesQuery extends Promise<unknown> {
105
+ returning(): Promise<unknown[]>;
106
+ }
107
+ interface SelectQuery extends Promise<unknown[]> {
108
+ where(condition: ReturnType<typeof and>): SelectQuery;
109
+ }
110
+ interface DrizzleTransactionLike {
111
+ insert(table: PgTable): {
112
+ values(values: Record<string, unknown> | Record<string, unknown>[]): InsertValuesQuery;
113
+ };
114
+ delete(table: PgTable): {
115
+ where(condition: ReturnType<typeof and>): Promise<unknown>;
116
+ };
117
+ select(selection?: Record<string, unknown>): {
118
+ from(table: PgTable): SelectQuery;
119
+ };
120
+ }
121
+ declare function extractMediaIds(fields: NpFieldConfig[], data: Record<string, unknown>): Array<{
122
+ mediaId: string;
123
+ field: string;
124
+ }>;
125
+ declare function syncMediaRefs(tx: DrizzleTransactionLike, collection: string, documentId: string, refs: Array<{
126
+ mediaId: string;
127
+ field: string;
128
+ }>): Promise<void>;
129
+
130
+ /**
131
+ * Built-in image variants. Plugin-defined custom variants are
132
+ * accepted as plain strings — the lookup walks `media.sizes`
133
+ * regardless of whether the variant was named in this union.
134
+ */
135
+ type NpMediaVariantName = "original" | "thumbnail" | "small" | "medium" | "large" | "xlarge" | "og" | (string & {});
136
+ interface NpGetMediaUrlOptions {
137
+ /**
138
+ * Which size to resolve. Defaults to `"original"` — the bytes
139
+ * uploaded by the user. Sized variants (`thumbnail`, `medium`,
140
+ * `og`, …) are only present for processed images; non-image
141
+ * media has only `"original"`.
142
+ */
143
+ variant?: NpMediaVariantName;
144
+ /**
145
+ * When `true` (default) and the requested variant doesn't
146
+ * exist on the media row, fall back to the original. Set to
147
+ * `false` to get `null` instead — useful when you'd rather
148
+ * skip rendering than serve a 5 MB original where a thumbnail
149
+ * was expected.
150
+ */
151
+ fallbackToOriginal?: boolean;
152
+ }
153
+ /**
154
+ * Resolve a media record's public URL via the active storage
155
+ * adapter — works the same for local-disk and S3 deployments,
156
+ * and uses the URL cached on the size record when present
157
+ * (avoids a redundant `presign` round-trip for S3).
158
+ *
159
+ * Returns `null` when:
160
+ * - the media id doesn't exist (or was soft-deleted),
161
+ * - the requested variant isn't available AND
162
+ * `fallbackToOriginal: false` was passed.
163
+ *
164
+ * Pure read — no side effects, safe to call from RSC.
165
+ */
166
+ declare function getMediaUrl(id: string, options?: NpGetMediaUrlOptions): Promise<string | null>;
167
+
168
+ export { DEFAULT_IMAGE_SIZES as D, type NpStorageAdapter as N, type NpFileMetadata as a, type NpGetMediaUrlOptions as b, type NpMediaUploader as c, type NpMediaUploaderKindFilter as d, type NpMediaVariantName as e, type NpProcessedImageResult as f, type NpProcessedImageVariant as g, cleanupDeletedMedia as h, deleteMedia as i, extractMediaIds as j, getMediaById as k, getMediaUrl as l, getStorageAdapter as m, listMedia as n, processMediaImage as o, processImage as p, type DrizzleTransactionLike as q, type NpProcessedImageSourceMetadata as r, setStorageAdapter as s, syncMediaRefs as t, uploadMedia as u };
@@ -0,0 +1,61 @@
1
+ import * as drizzle_orm_node_postgres from 'drizzle-orm/node-postgres';
2
+ import { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
+ import { Pool } from 'pg';
4
+ import { V as schema } from './index-CY55LC0u.js';
5
+ import { d as NpCollectionConfig } from './types-TlsbXS0T.js';
6
+
7
+ declare function setDb(db: NodePgDatabase<Record<string, unknown>>): void;
8
+ declare function getDb(): NodePgDatabase<Record<string, unknown>>;
9
+
10
+ interface CreateDbConnectionConfig {
11
+ connectionString: string;
12
+ pool?: Pool;
13
+ /**
14
+ * Override Pool option defaults. Useful for tests, or for sites that need
15
+ * to tune connection limits / timeouts. The fields explicitly set below
16
+ * (`connectionTimeoutMillis`, `statement_timeout`) win unless callers
17
+ * override them here.
18
+ */
19
+ poolOptions?: ConstructorParameters<typeof Pool>[0];
20
+ }
21
+ declare function createDbConnection(config: CreateDbConnectionConfig): drizzle_orm_node_postgres.NodePgDatabase<typeof schema> & {
22
+ $client: Pool;
23
+ };
24
+
25
+ interface GenerateDrizzleSchemaOptions {
26
+ /**
27
+ * Module specifier to import the core schema tables (npUsers, npMedia) from.
28
+ * Defaults to "@nexpress/core". Override when the consumer's tooling
29
+ * (e.g. drizzle-kit's CJS resolver) can't load the core package via its
30
+ * exports map — point at a relative path to core's source in that case.
31
+ */
32
+ schemaImport?: string;
33
+ }
34
+ declare function generateDrizzleSchema(collections: NpCollectionConfig[], options?: GenerateDrizzleSchemaOptions): string;
35
+
36
+ declare function generateTypeScript(collections: NpCollectionConfig[]): string;
37
+ /**
38
+ * Renders a complete `documents.ts` module: imports from
39
+ * `@nexpress/core`, per-collection `${Pascal}Document` interfaces,
40
+ * and typed read-helper wrappers (`find${Pascal}` /
41
+ * `get${Pascal}Document`) that bind the type generic so call sites
42
+ * don't have to.
43
+ *
44
+ * Collections with hasMany relationship fields get a smarter
45
+ * wrapper: when the caller's `where` clause names a hasMany
46
+ * field, the wrapper queries the join table for matching parent
47
+ * ids first, intersects across multiple hasMany filters, and
48
+ * delegates to `findDocuments` with `id: idList`. That covers
49
+ * the friction surfaced in #540's category-page dogfood — a
50
+ * `where: { categories: id }` filter looked typed but failed at
51
+ * runtime because `categories` isn't a column on the parent
52
+ * table; this wrapper makes it work.
53
+ *
54
+ * The output is meant for `apps/<app>/src/db/generated/documents.ts`
55
+ * and is a direct counterpart to `generateDrizzleSchema`'s
56
+ * `collections.ts` (Drizzle schema). Both files come from the same
57
+ * `nexpressConfig.collections` source so they stay in sync.
58
+ */
59
+ declare function generateDocumentsModule(collections: NpCollectionConfig[]): string;
60
+
61
+ export { type CreateDbConnectionConfig as C, generateDrizzleSchema as a, generateTypeScript as b, createDbConnection as c, getDb as d, generateDocumentsModule as g, setDb as s };