@siteping/adapter-kit 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.
- package/README.md +32 -0
- package/dist/chunk-YQHAD24P.js +97 -0
- package/dist/chunk-YQHAD24P.js.map +1 -0
- package/dist/errors.d.cts +41 -0
- package/dist/errors.d.ts +41 -0
- package/dist/filters.d.cts +33 -0
- package/dist/filters.d.ts +33 -0
- package/dist/i18n.d.cts +67 -0
- package/dist/i18n.d.ts +67 -0
- package/dist/index.cjs +256 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.cts +263 -0
- package/dist/schema.d.ts +263 -0
- package/dist/screenshot-storage.d.cts +61 -0
- package/dist/screenshot-storage.d.ts +61 -0
- package/dist/siteping-core-testing.d.cts +40 -0
- package/dist/siteping-core-testing.d.ts +40 -0
- package/dist/siteping-core.d.cts +16 -0
- package/dist/siteping-core.d.ts +16 -0
- package/dist/store-helpers.d.cts +87 -0
- package/dist/store-helpers.d.ts +87 -0
- package/dist/testing.cjs +484 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +1 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +433 -0
- package/dist/testing.js.map +1 -0
- package/dist/type-utils.d.cts +58 -0
- package/dist/type-utils.d.ts +58 -0
- package/dist/types.d.cts +840 -0
- package/dist/types.d.ts +840 -0
- package/dist/wire.d.cts +35 -0
- package/dist/wire.d.ts +35 -0
- package/package.json +77 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Siteping database models — single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* Used by:
|
|
5
|
+
* - CLI to generate Prisma schema (via prisma-ast)
|
|
6
|
+
* - Adapter for Zod validation
|
|
7
|
+
* - Type exports
|
|
8
|
+
*
|
|
9
|
+
* This is a TS representation, NOT a .prisma file.
|
|
10
|
+
* The CLI generates the actual Prisma schema from this definition.
|
|
11
|
+
*/
|
|
12
|
+
/** Prisma scalar types supported by Siteping field definitions. */
|
|
13
|
+
export type PrismaScalarType = "String" | "Boolean" | "Int" | "BigInt" | "Float" | "Decimal" | "DateTime" | "Json" | "Bytes";
|
|
14
|
+
/** Prisma native column hints applied via `@db.<NativeType>`. */
|
|
15
|
+
export type PrismaNativeType = "Text" | "VarChar" | "Char" | "MediumText" | "LongText" | (string & {});
|
|
16
|
+
/** Relation cardinality between two Siteping models. */
|
|
17
|
+
export type RelationKind = "1-to-many" | "many-to-1";
|
|
18
|
+
/** Prisma `onDelete` referential action. */
|
|
19
|
+
export type RelationOnDelete = "Cascade" | "Restrict" | "NoAction" | "SetNull" | "SetDefault";
|
|
20
|
+
/**
|
|
21
|
+
* Relation metadata attached to a {@link FieldDef}.
|
|
22
|
+
*
|
|
23
|
+
* - `1-to-many` fields point at the related model and require no inverse
|
|
24
|
+
* column on this side (`fields`/`references` are inferred by Prisma).
|
|
25
|
+
* - `many-to-1` fields own the foreign key — Prisma needs `fields` and
|
|
26
|
+
* `references` to wire it up.
|
|
27
|
+
*/
|
|
28
|
+
export interface RelationDef {
|
|
29
|
+
kind: RelationKind;
|
|
30
|
+
model: string;
|
|
31
|
+
fields?: readonly string[];
|
|
32
|
+
references?: readonly string[];
|
|
33
|
+
onDelete?: RelationOnDelete;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Definition of a single field in a Siteping database model.
|
|
37
|
+
*
|
|
38
|
+
* The interface intentionally keeps a wide structural shape so it stays
|
|
39
|
+
* easy to extend, but consumers can narrow via {@link isRelationField} /
|
|
40
|
+
* {@link isScalarField} when relation vs. scalar logic diverges.
|
|
41
|
+
*/
|
|
42
|
+
export interface FieldDef {
|
|
43
|
+
/** Prisma type (e.g. "String", "Int") for scalars, model name for relations. */
|
|
44
|
+
type: PrismaScalarType | (string & {});
|
|
45
|
+
/** Default literal (`"open"`) or function call (`now()`, `cuid()`). */
|
|
46
|
+
default?: string;
|
|
47
|
+
/** Whether the column is nullable. */
|
|
48
|
+
optional?: boolean;
|
|
49
|
+
/** Set on relation fields — absent on scalars. */
|
|
50
|
+
relation?: RelationDef;
|
|
51
|
+
isId?: boolean;
|
|
52
|
+
isUnique?: boolean;
|
|
53
|
+
/** Prisma native type attribute (e.g. "Text" for @db.Text) — used for MySQL compatibility on long strings */
|
|
54
|
+
nativeType?: PrismaNativeType;
|
|
55
|
+
/** Prisma @updatedAt attribute */
|
|
56
|
+
isUpdatedAt?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Narrowing predicate: returns `true` when `field` declares a Prisma relation. */
|
|
59
|
+
export declare function isRelationField(field: FieldDef): field is FieldDef & {
|
|
60
|
+
relation: RelationDef;
|
|
61
|
+
};
|
|
62
|
+
/** Narrowing predicate: returns `true` when `field` is a Prisma scalar (no relation metadata). */
|
|
63
|
+
export declare function isScalarField(field: FieldDef): field is FieldDef & {
|
|
64
|
+
relation?: undefined;
|
|
65
|
+
};
|
|
66
|
+
/** Definition of a composite index on a Siteping database model. */
|
|
67
|
+
export interface IndexDef {
|
|
68
|
+
fields: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
/** Definition of a single Siteping database model (fields + indexes). */
|
|
71
|
+
export interface ModelDef {
|
|
72
|
+
fields: Record<string, FieldDef>;
|
|
73
|
+
indexes?: readonly IndexDef[];
|
|
74
|
+
}
|
|
75
|
+
declare const _SITEPING_MODELS: {
|
|
76
|
+
readonly SitepingFeedback: {
|
|
77
|
+
readonly fields: {
|
|
78
|
+
readonly id: {
|
|
79
|
+
readonly type: "String";
|
|
80
|
+
readonly isId: true;
|
|
81
|
+
readonly default: "cuid()";
|
|
82
|
+
};
|
|
83
|
+
readonly projectName: {
|
|
84
|
+
readonly type: "String";
|
|
85
|
+
};
|
|
86
|
+
readonly type: {
|
|
87
|
+
readonly type: "String";
|
|
88
|
+
};
|
|
89
|
+
readonly message: {
|
|
90
|
+
readonly type: "String";
|
|
91
|
+
readonly nativeType: "Text";
|
|
92
|
+
};
|
|
93
|
+
readonly status: {
|
|
94
|
+
readonly type: "String";
|
|
95
|
+
readonly default: "\"open\"";
|
|
96
|
+
};
|
|
97
|
+
readonly url: {
|
|
98
|
+
readonly type: "String";
|
|
99
|
+
};
|
|
100
|
+
readonly urlPattern: {
|
|
101
|
+
readonly type: "String";
|
|
102
|
+
readonly optional: true;
|
|
103
|
+
};
|
|
104
|
+
readonly screenshotUrl: {
|
|
105
|
+
readonly type: "String";
|
|
106
|
+
readonly optional: true;
|
|
107
|
+
readonly nativeType: "Text";
|
|
108
|
+
};
|
|
109
|
+
readonly screenshotRegion: {
|
|
110
|
+
readonly type: "Json";
|
|
111
|
+
readonly optional: true;
|
|
112
|
+
};
|
|
113
|
+
readonly diagnostics: {
|
|
114
|
+
readonly type: "Json";
|
|
115
|
+
readonly optional: true;
|
|
116
|
+
};
|
|
117
|
+
readonly viewport: {
|
|
118
|
+
readonly type: "String";
|
|
119
|
+
};
|
|
120
|
+
readonly userAgent: {
|
|
121
|
+
readonly type: "String";
|
|
122
|
+
};
|
|
123
|
+
readonly authorName: {
|
|
124
|
+
readonly type: "String";
|
|
125
|
+
};
|
|
126
|
+
readonly authorEmail: {
|
|
127
|
+
readonly type: "String";
|
|
128
|
+
};
|
|
129
|
+
readonly clientId: {
|
|
130
|
+
readonly type: "String";
|
|
131
|
+
readonly isUnique: true;
|
|
132
|
+
};
|
|
133
|
+
readonly resolvedAt: {
|
|
134
|
+
readonly type: "DateTime";
|
|
135
|
+
readonly optional: true;
|
|
136
|
+
};
|
|
137
|
+
readonly createdAt: {
|
|
138
|
+
readonly type: "DateTime";
|
|
139
|
+
readonly default: "now()";
|
|
140
|
+
};
|
|
141
|
+
readonly updatedAt: {
|
|
142
|
+
readonly type: "DateTime";
|
|
143
|
+
readonly isUpdatedAt: true;
|
|
144
|
+
};
|
|
145
|
+
readonly annotations: {
|
|
146
|
+
readonly type: "SitepingAnnotation";
|
|
147
|
+
readonly relation: {
|
|
148
|
+
readonly kind: "1-to-many";
|
|
149
|
+
readonly model: "SitepingAnnotation";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
readonly indexes: readonly [{
|
|
154
|
+
readonly fields: readonly ["projectName"];
|
|
155
|
+
}, {
|
|
156
|
+
readonly fields: readonly ["projectName", "status", "createdAt"];
|
|
157
|
+
}, {
|
|
158
|
+
readonly fields: readonly ["projectName", "url"];
|
|
159
|
+
}];
|
|
160
|
+
};
|
|
161
|
+
readonly SitepingAnnotation: {
|
|
162
|
+
readonly fields: {
|
|
163
|
+
readonly id: {
|
|
164
|
+
readonly type: "String";
|
|
165
|
+
readonly isId: true;
|
|
166
|
+
readonly default: "cuid()";
|
|
167
|
+
};
|
|
168
|
+
readonly feedbackId: {
|
|
169
|
+
readonly type: "String";
|
|
170
|
+
};
|
|
171
|
+
readonly feedback: {
|
|
172
|
+
readonly type: "SitepingFeedback";
|
|
173
|
+
readonly relation: {
|
|
174
|
+
readonly kind: "many-to-1";
|
|
175
|
+
readonly model: "SitepingFeedback";
|
|
176
|
+
readonly fields: readonly ["feedbackId"];
|
|
177
|
+
readonly references: readonly ["id"];
|
|
178
|
+
readonly onDelete: "Cascade";
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
readonly cssSelector: {
|
|
182
|
+
readonly type: "String";
|
|
183
|
+
readonly nativeType: "Text";
|
|
184
|
+
};
|
|
185
|
+
readonly xpath: {
|
|
186
|
+
readonly type: "String";
|
|
187
|
+
readonly nativeType: "Text";
|
|
188
|
+
};
|
|
189
|
+
readonly textSnippet: {
|
|
190
|
+
readonly type: "String";
|
|
191
|
+
readonly nativeType: "Text";
|
|
192
|
+
};
|
|
193
|
+
readonly elementTag: {
|
|
194
|
+
readonly type: "String";
|
|
195
|
+
};
|
|
196
|
+
readonly elementId: {
|
|
197
|
+
readonly type: "String";
|
|
198
|
+
readonly optional: true;
|
|
199
|
+
};
|
|
200
|
+
readonly textPrefix: {
|
|
201
|
+
readonly type: "String";
|
|
202
|
+
readonly nativeType: "Text";
|
|
203
|
+
};
|
|
204
|
+
readonly textSuffix: {
|
|
205
|
+
readonly type: "String";
|
|
206
|
+
readonly nativeType: "Text";
|
|
207
|
+
};
|
|
208
|
+
readonly fingerprint: {
|
|
209
|
+
readonly type: "String";
|
|
210
|
+
};
|
|
211
|
+
readonly neighborText: {
|
|
212
|
+
readonly type: "String";
|
|
213
|
+
readonly nativeType: "Text";
|
|
214
|
+
};
|
|
215
|
+
readonly anchorKey: {
|
|
216
|
+
readonly type: "String";
|
|
217
|
+
readonly optional: true;
|
|
218
|
+
};
|
|
219
|
+
readonly xPct: {
|
|
220
|
+
readonly type: "Float";
|
|
221
|
+
};
|
|
222
|
+
readonly yPct: {
|
|
223
|
+
readonly type: "Float";
|
|
224
|
+
};
|
|
225
|
+
readonly wPct: {
|
|
226
|
+
readonly type: "Float";
|
|
227
|
+
};
|
|
228
|
+
readonly hPct: {
|
|
229
|
+
readonly type: "Float";
|
|
230
|
+
};
|
|
231
|
+
readonly scrollX: {
|
|
232
|
+
readonly type: "Float";
|
|
233
|
+
};
|
|
234
|
+
readonly scrollY: {
|
|
235
|
+
readonly type: "Float";
|
|
236
|
+
};
|
|
237
|
+
readonly viewportW: {
|
|
238
|
+
readonly type: "Int";
|
|
239
|
+
};
|
|
240
|
+
readonly viewportH: {
|
|
241
|
+
readonly type: "Int";
|
|
242
|
+
};
|
|
243
|
+
readonly devicePixelRatio: {
|
|
244
|
+
readonly type: "Float";
|
|
245
|
+
readonly default: "1";
|
|
246
|
+
};
|
|
247
|
+
readonly createdAt: {
|
|
248
|
+
readonly type: "DateTime";
|
|
249
|
+
readonly default: "now()";
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
readonly indexes: readonly [{
|
|
253
|
+
readonly fields: readonly ["feedbackId"];
|
|
254
|
+
}];
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
/** Map of Siteping models keyed by model name — frozen at runtime. */
|
|
258
|
+
export declare const SITEPING_MODELS: typeof _SITEPING_MODELS;
|
|
259
|
+
/** Union of every Siteping model name as a string literal. */
|
|
260
|
+
export type SitepingModelName = keyof typeof SITEPING_MODELS;
|
|
261
|
+
/** Field names declared on a specific Siteping model. */
|
|
262
|
+
export type SitepingModelFieldName<M extends SitepingModelName> = keyof (typeof SITEPING_MODELS)[M]["fields"];
|
|
263
|
+
export {};
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Siteping database models — single source of truth.
|
|
3
|
+
*
|
|
4
|
+
* Used by:
|
|
5
|
+
* - CLI to generate Prisma schema (via prisma-ast)
|
|
6
|
+
* - Adapter for Zod validation
|
|
7
|
+
* - Type exports
|
|
8
|
+
*
|
|
9
|
+
* This is a TS representation, NOT a .prisma file.
|
|
10
|
+
* The CLI generates the actual Prisma schema from this definition.
|
|
11
|
+
*/
|
|
12
|
+
/** Prisma scalar types supported by Siteping field definitions. */
|
|
13
|
+
export type PrismaScalarType = "String" | "Boolean" | "Int" | "BigInt" | "Float" | "Decimal" | "DateTime" | "Json" | "Bytes";
|
|
14
|
+
/** Prisma native column hints applied via `@db.<NativeType>`. */
|
|
15
|
+
export type PrismaNativeType = "Text" | "VarChar" | "Char" | "MediumText" | "LongText" | (string & {});
|
|
16
|
+
/** Relation cardinality between two Siteping models. */
|
|
17
|
+
export type RelationKind = "1-to-many" | "many-to-1";
|
|
18
|
+
/** Prisma `onDelete` referential action. */
|
|
19
|
+
export type RelationOnDelete = "Cascade" | "Restrict" | "NoAction" | "SetNull" | "SetDefault";
|
|
20
|
+
/**
|
|
21
|
+
* Relation metadata attached to a {@link FieldDef}.
|
|
22
|
+
*
|
|
23
|
+
* - `1-to-many` fields point at the related model and require no inverse
|
|
24
|
+
* column on this side (`fields`/`references` are inferred by Prisma).
|
|
25
|
+
* - `many-to-1` fields own the foreign key — Prisma needs `fields` and
|
|
26
|
+
* `references` to wire it up.
|
|
27
|
+
*/
|
|
28
|
+
export interface RelationDef {
|
|
29
|
+
kind: RelationKind;
|
|
30
|
+
model: string;
|
|
31
|
+
fields?: readonly string[];
|
|
32
|
+
references?: readonly string[];
|
|
33
|
+
onDelete?: RelationOnDelete;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Definition of a single field in a Siteping database model.
|
|
37
|
+
*
|
|
38
|
+
* The interface intentionally keeps a wide structural shape so it stays
|
|
39
|
+
* easy to extend, but consumers can narrow via {@link isRelationField} /
|
|
40
|
+
* {@link isScalarField} when relation vs. scalar logic diverges.
|
|
41
|
+
*/
|
|
42
|
+
export interface FieldDef {
|
|
43
|
+
/** Prisma type (e.g. "String", "Int") for scalars, model name for relations. */
|
|
44
|
+
type: PrismaScalarType | (string & {});
|
|
45
|
+
/** Default literal (`"open"`) or function call (`now()`, `cuid()`). */
|
|
46
|
+
default?: string;
|
|
47
|
+
/** Whether the column is nullable. */
|
|
48
|
+
optional?: boolean;
|
|
49
|
+
/** Set on relation fields — absent on scalars. */
|
|
50
|
+
relation?: RelationDef;
|
|
51
|
+
isId?: boolean;
|
|
52
|
+
isUnique?: boolean;
|
|
53
|
+
/** Prisma native type attribute (e.g. "Text" for @db.Text) — used for MySQL compatibility on long strings */
|
|
54
|
+
nativeType?: PrismaNativeType;
|
|
55
|
+
/** Prisma @updatedAt attribute */
|
|
56
|
+
isUpdatedAt?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Narrowing predicate: returns `true` when `field` declares a Prisma relation. */
|
|
59
|
+
export declare function isRelationField(field: FieldDef): field is FieldDef & {
|
|
60
|
+
relation: RelationDef;
|
|
61
|
+
};
|
|
62
|
+
/** Narrowing predicate: returns `true` when `field` is a Prisma scalar (no relation metadata). */
|
|
63
|
+
export declare function isScalarField(field: FieldDef): field is FieldDef & {
|
|
64
|
+
relation?: undefined;
|
|
65
|
+
};
|
|
66
|
+
/** Definition of a composite index on a Siteping database model. */
|
|
67
|
+
export interface IndexDef {
|
|
68
|
+
fields: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
/** Definition of a single Siteping database model (fields + indexes). */
|
|
71
|
+
export interface ModelDef {
|
|
72
|
+
fields: Record<string, FieldDef>;
|
|
73
|
+
indexes?: readonly IndexDef[];
|
|
74
|
+
}
|
|
75
|
+
declare const _SITEPING_MODELS: {
|
|
76
|
+
readonly SitepingFeedback: {
|
|
77
|
+
readonly fields: {
|
|
78
|
+
readonly id: {
|
|
79
|
+
readonly type: "String";
|
|
80
|
+
readonly isId: true;
|
|
81
|
+
readonly default: "cuid()";
|
|
82
|
+
};
|
|
83
|
+
readonly projectName: {
|
|
84
|
+
readonly type: "String";
|
|
85
|
+
};
|
|
86
|
+
readonly type: {
|
|
87
|
+
readonly type: "String";
|
|
88
|
+
};
|
|
89
|
+
readonly message: {
|
|
90
|
+
readonly type: "String";
|
|
91
|
+
readonly nativeType: "Text";
|
|
92
|
+
};
|
|
93
|
+
readonly status: {
|
|
94
|
+
readonly type: "String";
|
|
95
|
+
readonly default: "\"open\"";
|
|
96
|
+
};
|
|
97
|
+
readonly url: {
|
|
98
|
+
readonly type: "String";
|
|
99
|
+
};
|
|
100
|
+
readonly urlPattern: {
|
|
101
|
+
readonly type: "String";
|
|
102
|
+
readonly optional: true;
|
|
103
|
+
};
|
|
104
|
+
readonly screenshotUrl: {
|
|
105
|
+
readonly type: "String";
|
|
106
|
+
readonly optional: true;
|
|
107
|
+
readonly nativeType: "Text";
|
|
108
|
+
};
|
|
109
|
+
readonly screenshotRegion: {
|
|
110
|
+
readonly type: "Json";
|
|
111
|
+
readonly optional: true;
|
|
112
|
+
};
|
|
113
|
+
readonly diagnostics: {
|
|
114
|
+
readonly type: "Json";
|
|
115
|
+
readonly optional: true;
|
|
116
|
+
};
|
|
117
|
+
readonly viewport: {
|
|
118
|
+
readonly type: "String";
|
|
119
|
+
};
|
|
120
|
+
readonly userAgent: {
|
|
121
|
+
readonly type: "String";
|
|
122
|
+
};
|
|
123
|
+
readonly authorName: {
|
|
124
|
+
readonly type: "String";
|
|
125
|
+
};
|
|
126
|
+
readonly authorEmail: {
|
|
127
|
+
readonly type: "String";
|
|
128
|
+
};
|
|
129
|
+
readonly clientId: {
|
|
130
|
+
readonly type: "String";
|
|
131
|
+
readonly isUnique: true;
|
|
132
|
+
};
|
|
133
|
+
readonly resolvedAt: {
|
|
134
|
+
readonly type: "DateTime";
|
|
135
|
+
readonly optional: true;
|
|
136
|
+
};
|
|
137
|
+
readonly createdAt: {
|
|
138
|
+
readonly type: "DateTime";
|
|
139
|
+
readonly default: "now()";
|
|
140
|
+
};
|
|
141
|
+
readonly updatedAt: {
|
|
142
|
+
readonly type: "DateTime";
|
|
143
|
+
readonly isUpdatedAt: true;
|
|
144
|
+
};
|
|
145
|
+
readonly annotations: {
|
|
146
|
+
readonly type: "SitepingAnnotation";
|
|
147
|
+
readonly relation: {
|
|
148
|
+
readonly kind: "1-to-many";
|
|
149
|
+
readonly model: "SitepingAnnotation";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
readonly indexes: readonly [{
|
|
154
|
+
readonly fields: readonly ["projectName"];
|
|
155
|
+
}, {
|
|
156
|
+
readonly fields: readonly ["projectName", "status", "createdAt"];
|
|
157
|
+
}, {
|
|
158
|
+
readonly fields: readonly ["projectName", "url"];
|
|
159
|
+
}];
|
|
160
|
+
};
|
|
161
|
+
readonly SitepingAnnotation: {
|
|
162
|
+
readonly fields: {
|
|
163
|
+
readonly id: {
|
|
164
|
+
readonly type: "String";
|
|
165
|
+
readonly isId: true;
|
|
166
|
+
readonly default: "cuid()";
|
|
167
|
+
};
|
|
168
|
+
readonly feedbackId: {
|
|
169
|
+
readonly type: "String";
|
|
170
|
+
};
|
|
171
|
+
readonly feedback: {
|
|
172
|
+
readonly type: "SitepingFeedback";
|
|
173
|
+
readonly relation: {
|
|
174
|
+
readonly kind: "many-to-1";
|
|
175
|
+
readonly model: "SitepingFeedback";
|
|
176
|
+
readonly fields: readonly ["feedbackId"];
|
|
177
|
+
readonly references: readonly ["id"];
|
|
178
|
+
readonly onDelete: "Cascade";
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
readonly cssSelector: {
|
|
182
|
+
readonly type: "String";
|
|
183
|
+
readonly nativeType: "Text";
|
|
184
|
+
};
|
|
185
|
+
readonly xpath: {
|
|
186
|
+
readonly type: "String";
|
|
187
|
+
readonly nativeType: "Text";
|
|
188
|
+
};
|
|
189
|
+
readonly textSnippet: {
|
|
190
|
+
readonly type: "String";
|
|
191
|
+
readonly nativeType: "Text";
|
|
192
|
+
};
|
|
193
|
+
readonly elementTag: {
|
|
194
|
+
readonly type: "String";
|
|
195
|
+
};
|
|
196
|
+
readonly elementId: {
|
|
197
|
+
readonly type: "String";
|
|
198
|
+
readonly optional: true;
|
|
199
|
+
};
|
|
200
|
+
readonly textPrefix: {
|
|
201
|
+
readonly type: "String";
|
|
202
|
+
readonly nativeType: "Text";
|
|
203
|
+
};
|
|
204
|
+
readonly textSuffix: {
|
|
205
|
+
readonly type: "String";
|
|
206
|
+
readonly nativeType: "Text";
|
|
207
|
+
};
|
|
208
|
+
readonly fingerprint: {
|
|
209
|
+
readonly type: "String";
|
|
210
|
+
};
|
|
211
|
+
readonly neighborText: {
|
|
212
|
+
readonly type: "String";
|
|
213
|
+
readonly nativeType: "Text";
|
|
214
|
+
};
|
|
215
|
+
readonly anchorKey: {
|
|
216
|
+
readonly type: "String";
|
|
217
|
+
readonly optional: true;
|
|
218
|
+
};
|
|
219
|
+
readonly xPct: {
|
|
220
|
+
readonly type: "Float";
|
|
221
|
+
};
|
|
222
|
+
readonly yPct: {
|
|
223
|
+
readonly type: "Float";
|
|
224
|
+
};
|
|
225
|
+
readonly wPct: {
|
|
226
|
+
readonly type: "Float";
|
|
227
|
+
};
|
|
228
|
+
readonly hPct: {
|
|
229
|
+
readonly type: "Float";
|
|
230
|
+
};
|
|
231
|
+
readonly scrollX: {
|
|
232
|
+
readonly type: "Float";
|
|
233
|
+
};
|
|
234
|
+
readonly scrollY: {
|
|
235
|
+
readonly type: "Float";
|
|
236
|
+
};
|
|
237
|
+
readonly viewportW: {
|
|
238
|
+
readonly type: "Int";
|
|
239
|
+
};
|
|
240
|
+
readonly viewportH: {
|
|
241
|
+
readonly type: "Int";
|
|
242
|
+
};
|
|
243
|
+
readonly devicePixelRatio: {
|
|
244
|
+
readonly type: "Float";
|
|
245
|
+
readonly default: "1";
|
|
246
|
+
};
|
|
247
|
+
readonly createdAt: {
|
|
248
|
+
readonly type: "DateTime";
|
|
249
|
+
readonly default: "now()";
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
readonly indexes: readonly [{
|
|
253
|
+
readonly fields: readonly ["feedbackId"];
|
|
254
|
+
}];
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
/** Map of Siteping models keyed by model name — frozen at runtime. */
|
|
258
|
+
export declare const SITEPING_MODELS: typeof _SITEPING_MODELS;
|
|
259
|
+
/** Union of every Siteping model name as a string literal. */
|
|
260
|
+
export type SitepingModelName = keyof typeof SITEPING_MODELS;
|
|
261
|
+
/** Field names declared on a specific Siteping model. */
|
|
262
|
+
export type SitepingModelFieldName<M extends SitepingModelName> = keyof (typeof SITEPING_MODELS)[M]["fields"];
|
|
263
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable storage for feedback screenshots.
|
|
3
|
+
*
|
|
4
|
+
* `adapter-prisma` accepts an optional `screenshotStorage` config. When
|
|
5
|
+
* provided, the adapter forwards the widget-supplied data URL to `upload()`
|
|
6
|
+
* and persists the returned URL on `Feedback.screenshotUrl`. When not
|
|
7
|
+
* provided, the adapter falls back to inline base64 (with a one-time warn) —
|
|
8
|
+
* fine for dev and small deployments, a footgun for production Postgres.
|
|
9
|
+
*
|
|
10
|
+
* Implementations typically wrap an object store: S3, Cloudflare R2,
|
|
11
|
+
* Backblaze B2, Cloudflare Images, local filesystem, etc. They are
|
|
12
|
+
* intentionally not shipped from this package — wire your own based on
|
|
13
|
+
* existing infra.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Minimal S3 implementation
|
|
18
|
+
* import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
19
|
+
*
|
|
20
|
+
* const s3 = new S3Client({ region: "eu-west-3" });
|
|
21
|
+
* const screenshotStorage: ScreenshotStorage = {
|
|
22
|
+
* async upload(dataUrl, ctx) {
|
|
23
|
+
* const buf = Buffer.from(dataUrl.split(",")[1], "base64");
|
|
24
|
+
* const key = `feedback/${ctx.feedbackId}.jpg`;
|
|
25
|
+
* await s3.send(new PutObjectCommand({
|
|
26
|
+
* Bucket: "my-bucket", Key: key, Body: buf, ContentType: ctx.mimeType,
|
|
27
|
+
* }));
|
|
28
|
+
* return { url: `https://cdn.example.com/${key}` };
|
|
29
|
+
* },
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* createSitepingHandler({ prisma, screenshotStorage });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export interface ScreenshotStorage {
|
|
36
|
+
/**
|
|
37
|
+
* Persist a base64 data URL and return the URL the widget will use as
|
|
38
|
+
* `<img src>`. Implementations decide the underlying storage and any
|
|
39
|
+
* post-processing (resize, virus scan, content-type sniff).
|
|
40
|
+
*
|
|
41
|
+
* Adapters call this synchronously inside `createFeedback` — keep it
|
|
42
|
+
* fast or move to a queue if needed.
|
|
43
|
+
*
|
|
44
|
+
* **Security note:** `ctx.feedbackId` is the *client-generated* id
|
|
45
|
+
* (`clientId`) — the record id does not exist yet at upload time. Treat it
|
|
46
|
+
* as attacker-controlled: sanitize before using it in filesystem paths or
|
|
47
|
+
* object keys, even though server adapters validate its shape upstream.
|
|
48
|
+
*/
|
|
49
|
+
upload(dataUrl: string, ctx: {
|
|
50
|
+
feedbackId: string;
|
|
51
|
+
mimeType: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
url: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Optional cleanup hook called when the feedback is deleted. Adapters
|
|
57
|
+
* call this best-effort and swallow errors — orphaned objects are
|
|
58
|
+
* preferred over failed deletes.
|
|
59
|
+
*/
|
|
60
|
+
delete?: (url: string) => Promise<void>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pluggable storage for feedback screenshots.
|
|
3
|
+
*
|
|
4
|
+
* `adapter-prisma` accepts an optional `screenshotStorage` config. When
|
|
5
|
+
* provided, the adapter forwards the widget-supplied data URL to `upload()`
|
|
6
|
+
* and persists the returned URL on `Feedback.screenshotUrl`. When not
|
|
7
|
+
* provided, the adapter falls back to inline base64 (with a one-time warn) —
|
|
8
|
+
* fine for dev and small deployments, a footgun for production Postgres.
|
|
9
|
+
*
|
|
10
|
+
* Implementations typically wrap an object store: S3, Cloudflare R2,
|
|
11
|
+
* Backblaze B2, Cloudflare Images, local filesystem, etc. They are
|
|
12
|
+
* intentionally not shipped from this package — wire your own based on
|
|
13
|
+
* existing infra.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Minimal S3 implementation
|
|
18
|
+
* import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
19
|
+
*
|
|
20
|
+
* const s3 = new S3Client({ region: "eu-west-3" });
|
|
21
|
+
* const screenshotStorage: ScreenshotStorage = {
|
|
22
|
+
* async upload(dataUrl, ctx) {
|
|
23
|
+
* const buf = Buffer.from(dataUrl.split(",")[1], "base64");
|
|
24
|
+
* const key = `feedback/${ctx.feedbackId}.jpg`;
|
|
25
|
+
* await s3.send(new PutObjectCommand({
|
|
26
|
+
* Bucket: "my-bucket", Key: key, Body: buf, ContentType: ctx.mimeType,
|
|
27
|
+
* }));
|
|
28
|
+
* return { url: `https://cdn.example.com/${key}` };
|
|
29
|
+
* },
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* createSitepingHandler({ prisma, screenshotStorage });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export interface ScreenshotStorage {
|
|
36
|
+
/**
|
|
37
|
+
* Persist a base64 data URL and return the URL the widget will use as
|
|
38
|
+
* `<img src>`. Implementations decide the underlying storage and any
|
|
39
|
+
* post-processing (resize, virus scan, content-type sniff).
|
|
40
|
+
*
|
|
41
|
+
* Adapters call this synchronously inside `createFeedback` — keep it
|
|
42
|
+
* fast or move to a queue if needed.
|
|
43
|
+
*
|
|
44
|
+
* **Security note:** `ctx.feedbackId` is the *client-generated* id
|
|
45
|
+
* (`clientId`) — the record id does not exist yet at upload time. Treat it
|
|
46
|
+
* as attacker-controlled: sanitize before using it in filesystem paths or
|
|
47
|
+
* object keys, even though server adapters validate its shape upstream.
|
|
48
|
+
*/
|
|
49
|
+
upload(dataUrl: string, ctx: {
|
|
50
|
+
feedbackId: string;
|
|
51
|
+
mimeType: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
url: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Optional cleanup hook called when the feedback is deleted. Adapters
|
|
57
|
+
* call this best-effort and swallow errors — orphaned objects are
|
|
58
|
+
* preferred over failed deletes.
|
|
59
|
+
*/
|
|
60
|
+
delete?: (url: string) => Promise<void>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared conformance test suite for `SitepingStore` implementations.
|
|
3
|
+
*
|
|
4
|
+
* Adapters import this and run it with their store factory to verify they
|
|
5
|
+
* satisfy the full store contract — no need to write the same 40+ tests
|
|
6
|
+
* from scratch.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { testSitepingStore } from './siteping-core-testing.cjs'
|
|
11
|
+
* import { DrizzleStore } from '../src/index.js'
|
|
12
|
+
*
|
|
13
|
+
* testSitepingStore(() => new DrizzleStore(db))
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import type { SitepingStore } from "./types.cjs";
|
|
17
|
+
/** Tuning knobs for backends whose documented contract legitimately varies. */
|
|
18
|
+
export interface StoreConformanceOptions {
|
|
19
|
+
/**
|
|
20
|
+
* How `createFeedback` reacts to a duplicate `clientId` — both are valid
|
|
21
|
+
* per the `SitepingStore` contract:
|
|
22
|
+
* - `"return"` (default): idempotently return the existing record.
|
|
23
|
+
* - `"throw"`: throw `StoreDuplicateError` (matched via `isStoreDuplicate`).
|
|
24
|
+
*/
|
|
25
|
+
duplicateBehavior?: "return" | "throw" | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Whether `search` matches case-insensitively. Defaults to `true` (the
|
|
28
|
+
* in-memory pipeline's behavior). Set to `false` for SQL backends whose
|
|
29
|
+
* collation is case-sensitive — the suite then only asserts same-case
|
|
30
|
+
* substring matching.
|
|
31
|
+
*/
|
|
32
|
+
caseInsensitiveSearch?: boolean | undefined;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Run the full `SitepingStore` conformance test suite.
|
|
36
|
+
*
|
|
37
|
+
* @param factory — called before each test to create a fresh, empty store instance. May be async.
|
|
38
|
+
* @param options — contract variations, see {@link StoreConformanceOptions}.
|
|
39
|
+
*/
|
|
40
|
+
export declare function testSitepingStore(factory: () => SitepingStore | Promise<SitepingStore>, options?: StoreConformanceOptions): void;
|