create-einja-app 0.3.3 → 0.3.4
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/package.json +1 -1
- package/templates/default/.claude/settings.json +0 -4
- package/templates/default/.claude/skills/_einja-general-context-loader/SKILL.md +258 -0
- package/templates/default/.claude/skills/_einja-output-format/SKILL.md +211 -0
- package/templates/default/.claude/skills/_einja-project-overview/SKILL.md +29 -0
- package/templates/default/.claude/skills/_einja-spec-context-loader/SKILL.md +181 -0
- package/templates/default/.claude/skills/cli-package-specs/SKILL.md +53 -6
- package/templates/default/CLAUDE.md +18 -5
- package/templates/default/docs/plans/glistening-conjuring-cascade.md +42 -0
- package/templates/default/docs/plans/linear-gathering-hejlsberg.md +596 -0
- package/templates/default/docs/plans/todo-glistening-conjuring-cascade.md +20 -0
- package/templates/default/docs/plans/todo-unified-crafting-valiant.md +23 -0
- package/templates/default/docs/plans/unified-crafting-valiant.md +60 -0
- package/templates/default/scripts/ensure-serena.sh +26 -7
- package/templates/default/.claude/hooks/einja/validate-git-commit.sh +0 -239
- package/templates/default/packages/server-core/src/__generated__/fabbrica/index.d.ts +0 -270
- package/templates/default/packages/server-core/src/__generated__/fabbrica/index.js +0 -484
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
import { createInitializer, createScreener, getScalarFieldValueGenerator, normalizeResolver, normalizeList, getSequenceCounter, createCallbackChain, destructure } from "@quramy/prisma-fabbrica/lib/internal";
|
|
2
|
-
export { resetSequence, registerScalarFieldValueGenerator, resetScalarFieldValueGenerator } from "@quramy/prisma-fabbrica/lib/internal";
|
|
3
|
-
const initializer = createInitializer();
|
|
4
|
-
const { getClient } = initializer;
|
|
5
|
-
export const { initialize } = initializer;
|
|
6
|
-
const modelFieldDefinitions = [{
|
|
7
|
-
name: "User",
|
|
8
|
-
fields: [{
|
|
9
|
-
name: "accounts",
|
|
10
|
-
type: "Account",
|
|
11
|
-
relationName: "AccountToUser"
|
|
12
|
-
}, {
|
|
13
|
-
name: "sessions",
|
|
14
|
-
type: "Session",
|
|
15
|
-
relationName: "SessionToUser"
|
|
16
|
-
}, {
|
|
17
|
-
name: "Authenticator",
|
|
18
|
-
type: "Authenticator",
|
|
19
|
-
relationName: "AuthenticatorToUser"
|
|
20
|
-
}]
|
|
21
|
-
}, {
|
|
22
|
-
name: "Account",
|
|
23
|
-
fields: [{
|
|
24
|
-
name: "user",
|
|
25
|
-
type: "User",
|
|
26
|
-
relationName: "AccountToUser"
|
|
27
|
-
}]
|
|
28
|
-
}, {
|
|
29
|
-
name: "Session",
|
|
30
|
-
fields: [{
|
|
31
|
-
name: "user",
|
|
32
|
-
type: "User",
|
|
33
|
-
relationName: "SessionToUser"
|
|
34
|
-
}]
|
|
35
|
-
}, {
|
|
36
|
-
name: "VerificationToken",
|
|
37
|
-
fields: []
|
|
38
|
-
}, {
|
|
39
|
-
name: "Authenticator",
|
|
40
|
-
fields: [{
|
|
41
|
-
name: "user",
|
|
42
|
-
type: "User",
|
|
43
|
-
relationName: "AuthenticatorToUser"
|
|
44
|
-
}]
|
|
45
|
-
}];
|
|
46
|
-
function autoGenerateUserScalarsOrEnums({ seq }) {
|
|
47
|
-
return {
|
|
48
|
-
email: getScalarFieldValueGenerator().String({ modelName: "User", fieldName: "email", isId: false, isUnique: true, seq })
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function defineUserFactoryInternal({ defaultData: defaultDataResolver, onAfterBuild, onBeforeCreate, onAfterCreate, traits: traitsDefs = {} }, defaultTransientFieldValues) {
|
|
52
|
-
const getFactoryWithTraits = (traitKeys = []) => {
|
|
53
|
-
const seqKey = {};
|
|
54
|
-
const getSeq = () => getSequenceCounter(seqKey);
|
|
55
|
-
const screen = createScreener("User", modelFieldDefinitions);
|
|
56
|
-
const handleAfterBuild = createCallbackChain([
|
|
57
|
-
onAfterBuild,
|
|
58
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterBuild; }),
|
|
59
|
-
]);
|
|
60
|
-
const handleBeforeCreate = createCallbackChain([
|
|
61
|
-
...traitKeys.slice().reverse().map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onBeforeCreate; }),
|
|
62
|
-
onBeforeCreate,
|
|
63
|
-
]);
|
|
64
|
-
const handleAfterCreate = createCallbackChain([
|
|
65
|
-
onAfterCreate,
|
|
66
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterCreate; }),
|
|
67
|
-
]);
|
|
68
|
-
const build = async (inputData = {}) => {
|
|
69
|
-
const seq = getSeq();
|
|
70
|
-
const requiredScalarData = autoGenerateUserScalarsOrEnums({ seq });
|
|
71
|
-
const resolveValue = normalizeResolver(defaultDataResolver !== null && defaultDataResolver !== void 0 ? defaultDataResolver : {});
|
|
72
|
-
const [transientFields, filteredInputData] = destructure(defaultTransientFieldValues, inputData);
|
|
73
|
-
const resolverInput = Object.assign({ seq }, transientFields);
|
|
74
|
-
const defaultData = await traitKeys.reduce(async (queue, traitKey) => {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
const acc = await queue;
|
|
77
|
-
const resolveTraitValue = normalizeResolver((_b = (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {});
|
|
78
|
-
const traitData = await resolveTraitValue(resolverInput);
|
|
79
|
-
return Object.assign(Object.assign({}, acc), traitData);
|
|
80
|
-
}, resolveValue(resolverInput));
|
|
81
|
-
const defaultAssociations = {};
|
|
82
|
-
const data = Object.assign(Object.assign(Object.assign(Object.assign({}, requiredScalarData), defaultData), defaultAssociations), filteredInputData);
|
|
83
|
-
await handleAfterBuild(data, transientFields);
|
|
84
|
-
return data;
|
|
85
|
-
};
|
|
86
|
-
const buildList = (...args) => Promise.all(normalizeList(...args).map(data => build(data)));
|
|
87
|
-
const pickForConnect = (inputData) => ({
|
|
88
|
-
id: inputData.id
|
|
89
|
-
});
|
|
90
|
-
const create = async (inputData = {}) => {
|
|
91
|
-
const data = await build(Object.assign({}, inputData)).then(screen);
|
|
92
|
-
const [transientFields] = destructure(defaultTransientFieldValues, inputData);
|
|
93
|
-
await handleBeforeCreate(data, transientFields);
|
|
94
|
-
const createdData = await getClient().user.create({ data });
|
|
95
|
-
await handleAfterCreate(createdData, transientFields);
|
|
96
|
-
return createdData;
|
|
97
|
-
};
|
|
98
|
-
const createList = (...args) => Promise.all(normalizeList(...args).map(data => create(data)));
|
|
99
|
-
const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
|
|
100
|
-
return {
|
|
101
|
-
_factoryFor: "User",
|
|
102
|
-
build,
|
|
103
|
-
buildList,
|
|
104
|
-
buildCreateInput: build,
|
|
105
|
-
pickForConnect,
|
|
106
|
-
create,
|
|
107
|
-
createList,
|
|
108
|
-
createForConnect,
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const factory = getFactoryWithTraits();
|
|
112
|
-
const useTraits = (name, ...names) => {
|
|
113
|
-
return getFactoryWithTraits([name, ...names]);
|
|
114
|
-
};
|
|
115
|
-
return Object.assign(Object.assign({}, factory), { use: useTraits });
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Define factory for {@link User} model.
|
|
119
|
-
*
|
|
120
|
-
* @param options
|
|
121
|
-
* @returns factory {@link UserFactoryInterface}
|
|
122
|
-
*/
|
|
123
|
-
export const defineUserFactory = ((options) => {
|
|
124
|
-
return defineUserFactoryInternal(options !== null && options !== void 0 ? options : {}, {});
|
|
125
|
-
});
|
|
126
|
-
defineUserFactory.withTransientFields = defaultTransientFieldValues => options => defineUserFactoryInternal(options !== null && options !== void 0 ? options : {}, defaultTransientFieldValues);
|
|
127
|
-
function isAccountuserFactory(x) {
|
|
128
|
-
return (x === null || x === void 0 ? void 0 : x._factoryFor) === "User";
|
|
129
|
-
}
|
|
130
|
-
function autoGenerateAccountScalarsOrEnums({ seq }) {
|
|
131
|
-
return {
|
|
132
|
-
type: getScalarFieldValueGenerator().String({ modelName: "Account", fieldName: "type", isId: false, isUnique: false, seq }),
|
|
133
|
-
provider: getScalarFieldValueGenerator().String({ modelName: "Account", fieldName: "provider", isId: true, isUnique: false, seq }),
|
|
134
|
-
providerAccountId: getScalarFieldValueGenerator().String({ modelName: "Account", fieldName: "providerAccountId", isId: true, isUnique: false, seq })
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
function defineAccountFactoryInternal({ defaultData: defaultDataResolver, onAfterBuild, onBeforeCreate, onAfterCreate, traits: traitsDefs = {} }, defaultTransientFieldValues) {
|
|
138
|
-
const getFactoryWithTraits = (traitKeys = []) => {
|
|
139
|
-
const seqKey = {};
|
|
140
|
-
const getSeq = () => getSequenceCounter(seqKey);
|
|
141
|
-
const screen = createScreener("Account", modelFieldDefinitions);
|
|
142
|
-
const handleAfterBuild = createCallbackChain([
|
|
143
|
-
onAfterBuild,
|
|
144
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterBuild; }),
|
|
145
|
-
]);
|
|
146
|
-
const handleBeforeCreate = createCallbackChain([
|
|
147
|
-
...traitKeys.slice().reverse().map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onBeforeCreate; }),
|
|
148
|
-
onBeforeCreate,
|
|
149
|
-
]);
|
|
150
|
-
const handleAfterCreate = createCallbackChain([
|
|
151
|
-
onAfterCreate,
|
|
152
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterCreate; }),
|
|
153
|
-
]);
|
|
154
|
-
const build = async (inputData = {}) => {
|
|
155
|
-
const seq = getSeq();
|
|
156
|
-
const requiredScalarData = autoGenerateAccountScalarsOrEnums({ seq });
|
|
157
|
-
const resolveValue = normalizeResolver(defaultDataResolver);
|
|
158
|
-
const [transientFields, filteredInputData] = destructure(defaultTransientFieldValues, inputData);
|
|
159
|
-
const resolverInput = Object.assign({ seq }, transientFields);
|
|
160
|
-
const defaultData = await traitKeys.reduce(async (queue, traitKey) => {
|
|
161
|
-
var _a, _b;
|
|
162
|
-
const acc = await queue;
|
|
163
|
-
const resolveTraitValue = normalizeResolver((_b = (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {});
|
|
164
|
-
const traitData = await resolveTraitValue(resolverInput);
|
|
165
|
-
return Object.assign(Object.assign({}, acc), traitData);
|
|
166
|
-
}, resolveValue(resolverInput));
|
|
167
|
-
const defaultAssociations = {
|
|
168
|
-
user: isAccountuserFactory(defaultData.user) ? {
|
|
169
|
-
create: await defaultData.user.build()
|
|
170
|
-
} : defaultData.user
|
|
171
|
-
};
|
|
172
|
-
const data = Object.assign(Object.assign(Object.assign(Object.assign({}, requiredScalarData), defaultData), defaultAssociations), filteredInputData);
|
|
173
|
-
await handleAfterBuild(data, transientFields);
|
|
174
|
-
return data;
|
|
175
|
-
};
|
|
176
|
-
const buildList = (...args) => Promise.all(normalizeList(...args).map(data => build(data)));
|
|
177
|
-
const pickForConnect = (inputData) => ({
|
|
178
|
-
provider: inputData.provider,
|
|
179
|
-
providerAccountId: inputData.providerAccountId
|
|
180
|
-
});
|
|
181
|
-
const create = async (inputData = {}) => {
|
|
182
|
-
const data = await build(Object.assign({}, inputData)).then(screen);
|
|
183
|
-
const [transientFields] = destructure(defaultTransientFieldValues, inputData);
|
|
184
|
-
await handleBeforeCreate(data, transientFields);
|
|
185
|
-
const createdData = await getClient().account.create({ data });
|
|
186
|
-
await handleAfterCreate(createdData, transientFields);
|
|
187
|
-
return createdData;
|
|
188
|
-
};
|
|
189
|
-
const createList = (...args) => Promise.all(normalizeList(...args).map(data => create(data)));
|
|
190
|
-
const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
|
|
191
|
-
return {
|
|
192
|
-
_factoryFor: "Account",
|
|
193
|
-
build,
|
|
194
|
-
buildList,
|
|
195
|
-
buildCreateInput: build,
|
|
196
|
-
pickForConnect,
|
|
197
|
-
create,
|
|
198
|
-
createList,
|
|
199
|
-
createForConnect,
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
const factory = getFactoryWithTraits();
|
|
203
|
-
const useTraits = (name, ...names) => {
|
|
204
|
-
return getFactoryWithTraits([name, ...names]);
|
|
205
|
-
};
|
|
206
|
-
return Object.assign(Object.assign({}, factory), { use: useTraits });
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Define factory for {@link Account} model.
|
|
210
|
-
*
|
|
211
|
-
* @param options
|
|
212
|
-
* @returns factory {@link AccountFactoryInterface}
|
|
213
|
-
*/
|
|
214
|
-
export const defineAccountFactory = ((options) => {
|
|
215
|
-
return defineAccountFactoryInternal(options, {});
|
|
216
|
-
});
|
|
217
|
-
defineAccountFactory.withTransientFields = defaultTransientFieldValues => options => defineAccountFactoryInternal(options, defaultTransientFieldValues);
|
|
218
|
-
function isSessionuserFactory(x) {
|
|
219
|
-
return (x === null || x === void 0 ? void 0 : x._factoryFor) === "User";
|
|
220
|
-
}
|
|
221
|
-
function autoGenerateSessionScalarsOrEnums({ seq }) {
|
|
222
|
-
return {
|
|
223
|
-
sessionToken: getScalarFieldValueGenerator().String({ modelName: "Session", fieldName: "sessionToken", isId: false, isUnique: true, seq }),
|
|
224
|
-
expires: getScalarFieldValueGenerator().DateTime({ modelName: "Session", fieldName: "expires", isId: false, isUnique: false, seq })
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function defineSessionFactoryInternal({ defaultData: defaultDataResolver, onAfterBuild, onBeforeCreate, onAfterCreate, traits: traitsDefs = {} }, defaultTransientFieldValues) {
|
|
228
|
-
const getFactoryWithTraits = (traitKeys = []) => {
|
|
229
|
-
const seqKey = {};
|
|
230
|
-
const getSeq = () => getSequenceCounter(seqKey);
|
|
231
|
-
const screen = createScreener("Session", modelFieldDefinitions);
|
|
232
|
-
const handleAfterBuild = createCallbackChain([
|
|
233
|
-
onAfterBuild,
|
|
234
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterBuild; }),
|
|
235
|
-
]);
|
|
236
|
-
const handleBeforeCreate = createCallbackChain([
|
|
237
|
-
...traitKeys.slice().reverse().map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onBeforeCreate; }),
|
|
238
|
-
onBeforeCreate,
|
|
239
|
-
]);
|
|
240
|
-
const handleAfterCreate = createCallbackChain([
|
|
241
|
-
onAfterCreate,
|
|
242
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterCreate; }),
|
|
243
|
-
]);
|
|
244
|
-
const build = async (inputData = {}) => {
|
|
245
|
-
const seq = getSeq();
|
|
246
|
-
const requiredScalarData = autoGenerateSessionScalarsOrEnums({ seq });
|
|
247
|
-
const resolveValue = normalizeResolver(defaultDataResolver);
|
|
248
|
-
const [transientFields, filteredInputData] = destructure(defaultTransientFieldValues, inputData);
|
|
249
|
-
const resolverInput = Object.assign({ seq }, transientFields);
|
|
250
|
-
const defaultData = await traitKeys.reduce(async (queue, traitKey) => {
|
|
251
|
-
var _a, _b;
|
|
252
|
-
const acc = await queue;
|
|
253
|
-
const resolveTraitValue = normalizeResolver((_b = (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {});
|
|
254
|
-
const traitData = await resolveTraitValue(resolverInput);
|
|
255
|
-
return Object.assign(Object.assign({}, acc), traitData);
|
|
256
|
-
}, resolveValue(resolverInput));
|
|
257
|
-
const defaultAssociations = {
|
|
258
|
-
user: isSessionuserFactory(defaultData.user) ? {
|
|
259
|
-
create: await defaultData.user.build()
|
|
260
|
-
} : defaultData.user
|
|
261
|
-
};
|
|
262
|
-
const data = Object.assign(Object.assign(Object.assign(Object.assign({}, requiredScalarData), defaultData), defaultAssociations), filteredInputData);
|
|
263
|
-
await handleAfterBuild(data, transientFields);
|
|
264
|
-
return data;
|
|
265
|
-
};
|
|
266
|
-
const buildList = (...args) => Promise.all(normalizeList(...args).map(data => build(data)));
|
|
267
|
-
const pickForConnect = (inputData) => ({
|
|
268
|
-
sessionToken: inputData.sessionToken
|
|
269
|
-
});
|
|
270
|
-
const create = async (inputData = {}) => {
|
|
271
|
-
const data = await build(Object.assign({}, inputData)).then(screen);
|
|
272
|
-
const [transientFields] = destructure(defaultTransientFieldValues, inputData);
|
|
273
|
-
await handleBeforeCreate(data, transientFields);
|
|
274
|
-
const createdData = await getClient().session.create({ data });
|
|
275
|
-
await handleAfterCreate(createdData, transientFields);
|
|
276
|
-
return createdData;
|
|
277
|
-
};
|
|
278
|
-
const createList = (...args) => Promise.all(normalizeList(...args).map(data => create(data)));
|
|
279
|
-
const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
|
|
280
|
-
return {
|
|
281
|
-
_factoryFor: "Session",
|
|
282
|
-
build,
|
|
283
|
-
buildList,
|
|
284
|
-
buildCreateInput: build,
|
|
285
|
-
pickForConnect,
|
|
286
|
-
create,
|
|
287
|
-
createList,
|
|
288
|
-
createForConnect,
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
|
-
const factory = getFactoryWithTraits();
|
|
292
|
-
const useTraits = (name, ...names) => {
|
|
293
|
-
return getFactoryWithTraits([name, ...names]);
|
|
294
|
-
};
|
|
295
|
-
return Object.assign(Object.assign({}, factory), { use: useTraits });
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Define factory for {@link Session} model.
|
|
299
|
-
*
|
|
300
|
-
* @param options
|
|
301
|
-
* @returns factory {@link SessionFactoryInterface}
|
|
302
|
-
*/
|
|
303
|
-
export const defineSessionFactory = ((options) => {
|
|
304
|
-
return defineSessionFactoryInternal(options, {});
|
|
305
|
-
});
|
|
306
|
-
defineSessionFactory.withTransientFields = defaultTransientFieldValues => options => defineSessionFactoryInternal(options, defaultTransientFieldValues);
|
|
307
|
-
function autoGenerateVerificationTokenScalarsOrEnums({ seq }) {
|
|
308
|
-
return {
|
|
309
|
-
identifier: getScalarFieldValueGenerator().String({ modelName: "VerificationToken", fieldName: "identifier", isId: true, isUnique: false, seq }),
|
|
310
|
-
token: getScalarFieldValueGenerator().String({ modelName: "VerificationToken", fieldName: "token", isId: true, isUnique: false, seq }),
|
|
311
|
-
expires: getScalarFieldValueGenerator().DateTime({ modelName: "VerificationToken", fieldName: "expires", isId: false, isUnique: false, seq })
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
function defineVerificationTokenFactoryInternal({ defaultData: defaultDataResolver, onAfterBuild, onBeforeCreate, onAfterCreate, traits: traitsDefs = {} }, defaultTransientFieldValues) {
|
|
315
|
-
const getFactoryWithTraits = (traitKeys = []) => {
|
|
316
|
-
const seqKey = {};
|
|
317
|
-
const getSeq = () => getSequenceCounter(seqKey);
|
|
318
|
-
const screen = createScreener("VerificationToken", modelFieldDefinitions);
|
|
319
|
-
const handleAfterBuild = createCallbackChain([
|
|
320
|
-
onAfterBuild,
|
|
321
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterBuild; }),
|
|
322
|
-
]);
|
|
323
|
-
const handleBeforeCreate = createCallbackChain([
|
|
324
|
-
...traitKeys.slice().reverse().map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onBeforeCreate; }),
|
|
325
|
-
onBeforeCreate,
|
|
326
|
-
]);
|
|
327
|
-
const handleAfterCreate = createCallbackChain([
|
|
328
|
-
onAfterCreate,
|
|
329
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterCreate; }),
|
|
330
|
-
]);
|
|
331
|
-
const build = async (inputData = {}) => {
|
|
332
|
-
const seq = getSeq();
|
|
333
|
-
const requiredScalarData = autoGenerateVerificationTokenScalarsOrEnums({ seq });
|
|
334
|
-
const resolveValue = normalizeResolver(defaultDataResolver !== null && defaultDataResolver !== void 0 ? defaultDataResolver : {});
|
|
335
|
-
const [transientFields, filteredInputData] = destructure(defaultTransientFieldValues, inputData);
|
|
336
|
-
const resolverInput = Object.assign({ seq }, transientFields);
|
|
337
|
-
const defaultData = await traitKeys.reduce(async (queue, traitKey) => {
|
|
338
|
-
var _a, _b;
|
|
339
|
-
const acc = await queue;
|
|
340
|
-
const resolveTraitValue = normalizeResolver((_b = (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {});
|
|
341
|
-
const traitData = await resolveTraitValue(resolverInput);
|
|
342
|
-
return Object.assign(Object.assign({}, acc), traitData);
|
|
343
|
-
}, resolveValue(resolverInput));
|
|
344
|
-
const defaultAssociations = {};
|
|
345
|
-
const data = Object.assign(Object.assign(Object.assign(Object.assign({}, requiredScalarData), defaultData), defaultAssociations), filteredInputData);
|
|
346
|
-
await handleAfterBuild(data, transientFields);
|
|
347
|
-
return data;
|
|
348
|
-
};
|
|
349
|
-
const buildList = (...args) => Promise.all(normalizeList(...args).map(data => build(data)));
|
|
350
|
-
const pickForConnect = (inputData) => ({
|
|
351
|
-
identifier: inputData.identifier,
|
|
352
|
-
token: inputData.token
|
|
353
|
-
});
|
|
354
|
-
const create = async (inputData = {}) => {
|
|
355
|
-
const data = await build(Object.assign({}, inputData)).then(screen);
|
|
356
|
-
const [transientFields] = destructure(defaultTransientFieldValues, inputData);
|
|
357
|
-
await handleBeforeCreate(data, transientFields);
|
|
358
|
-
const createdData = await getClient().verificationToken.create({ data });
|
|
359
|
-
await handleAfterCreate(createdData, transientFields);
|
|
360
|
-
return createdData;
|
|
361
|
-
};
|
|
362
|
-
const createList = (...args) => Promise.all(normalizeList(...args).map(data => create(data)));
|
|
363
|
-
const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
|
|
364
|
-
return {
|
|
365
|
-
_factoryFor: "VerificationToken",
|
|
366
|
-
build,
|
|
367
|
-
buildList,
|
|
368
|
-
buildCreateInput: build,
|
|
369
|
-
pickForConnect,
|
|
370
|
-
create,
|
|
371
|
-
createList,
|
|
372
|
-
createForConnect,
|
|
373
|
-
};
|
|
374
|
-
};
|
|
375
|
-
const factory = getFactoryWithTraits();
|
|
376
|
-
const useTraits = (name, ...names) => {
|
|
377
|
-
return getFactoryWithTraits([name, ...names]);
|
|
378
|
-
};
|
|
379
|
-
return Object.assign(Object.assign({}, factory), { use: useTraits });
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Define factory for {@link VerificationToken} model.
|
|
383
|
-
*
|
|
384
|
-
* @param options
|
|
385
|
-
* @returns factory {@link VerificationTokenFactoryInterface}
|
|
386
|
-
*/
|
|
387
|
-
export const defineVerificationTokenFactory = ((options) => {
|
|
388
|
-
return defineVerificationTokenFactoryInternal(options !== null && options !== void 0 ? options : {}, {});
|
|
389
|
-
});
|
|
390
|
-
defineVerificationTokenFactory.withTransientFields = defaultTransientFieldValues => options => defineVerificationTokenFactoryInternal(options !== null && options !== void 0 ? options : {}, defaultTransientFieldValues);
|
|
391
|
-
function isAuthenticatoruserFactory(x) {
|
|
392
|
-
return (x === null || x === void 0 ? void 0 : x._factoryFor) === "User";
|
|
393
|
-
}
|
|
394
|
-
function autoGenerateAuthenticatorScalarsOrEnums({ seq }) {
|
|
395
|
-
return {
|
|
396
|
-
credentialID: getScalarFieldValueGenerator().String({ modelName: "Authenticator", fieldName: "credentialID", isId: true, isUnique: true, seq }),
|
|
397
|
-
providerAccountId: getScalarFieldValueGenerator().String({ modelName: "Authenticator", fieldName: "providerAccountId", isId: false, isUnique: false, seq }),
|
|
398
|
-
credentialPublicKey: getScalarFieldValueGenerator().String({ modelName: "Authenticator", fieldName: "credentialPublicKey", isId: false, isUnique: false, seq }),
|
|
399
|
-
counter: getScalarFieldValueGenerator().Int({ modelName: "Authenticator", fieldName: "counter", isId: false, isUnique: false, seq }),
|
|
400
|
-
credentialDeviceType: getScalarFieldValueGenerator().String({ modelName: "Authenticator", fieldName: "credentialDeviceType", isId: false, isUnique: false, seq }),
|
|
401
|
-
credentialBackedUp: getScalarFieldValueGenerator().Boolean({ modelName: "Authenticator", fieldName: "credentialBackedUp", isId: false, isUnique: false, seq })
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
function defineAuthenticatorFactoryInternal({ defaultData: defaultDataResolver, onAfterBuild, onBeforeCreate, onAfterCreate, traits: traitsDefs = {} }, defaultTransientFieldValues) {
|
|
405
|
-
const getFactoryWithTraits = (traitKeys = []) => {
|
|
406
|
-
const seqKey = {};
|
|
407
|
-
const getSeq = () => getSequenceCounter(seqKey);
|
|
408
|
-
const screen = createScreener("Authenticator", modelFieldDefinitions);
|
|
409
|
-
const handleAfterBuild = createCallbackChain([
|
|
410
|
-
onAfterBuild,
|
|
411
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterBuild; }),
|
|
412
|
-
]);
|
|
413
|
-
const handleBeforeCreate = createCallbackChain([
|
|
414
|
-
...traitKeys.slice().reverse().map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onBeforeCreate; }),
|
|
415
|
-
onBeforeCreate,
|
|
416
|
-
]);
|
|
417
|
-
const handleAfterCreate = createCallbackChain([
|
|
418
|
-
onAfterCreate,
|
|
419
|
-
...traitKeys.map(traitKey => { var _a; return (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.onAfterCreate; }),
|
|
420
|
-
]);
|
|
421
|
-
const build = async (inputData = {}) => {
|
|
422
|
-
const seq = getSeq();
|
|
423
|
-
const requiredScalarData = autoGenerateAuthenticatorScalarsOrEnums({ seq });
|
|
424
|
-
const resolveValue = normalizeResolver(defaultDataResolver);
|
|
425
|
-
const [transientFields, filteredInputData] = destructure(defaultTransientFieldValues, inputData);
|
|
426
|
-
const resolverInput = Object.assign({ seq }, transientFields);
|
|
427
|
-
const defaultData = await traitKeys.reduce(async (queue, traitKey) => {
|
|
428
|
-
var _a, _b;
|
|
429
|
-
const acc = await queue;
|
|
430
|
-
const resolveTraitValue = normalizeResolver((_b = (_a = traitsDefs[traitKey]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : {});
|
|
431
|
-
const traitData = await resolveTraitValue(resolverInput);
|
|
432
|
-
return Object.assign(Object.assign({}, acc), traitData);
|
|
433
|
-
}, resolveValue(resolverInput));
|
|
434
|
-
const defaultAssociations = {
|
|
435
|
-
user: isAuthenticatoruserFactory(defaultData.user) ? {
|
|
436
|
-
create: await defaultData.user.build()
|
|
437
|
-
} : defaultData.user
|
|
438
|
-
};
|
|
439
|
-
const data = Object.assign(Object.assign(Object.assign(Object.assign({}, requiredScalarData), defaultData), defaultAssociations), filteredInputData);
|
|
440
|
-
await handleAfterBuild(data, transientFields);
|
|
441
|
-
return data;
|
|
442
|
-
};
|
|
443
|
-
const buildList = (...args) => Promise.all(normalizeList(...args).map(data => build(data)));
|
|
444
|
-
const pickForConnect = (inputData) => ({
|
|
445
|
-
userId: inputData.userId,
|
|
446
|
-
credentialID: inputData.credentialID
|
|
447
|
-
});
|
|
448
|
-
const create = async (inputData = {}) => {
|
|
449
|
-
const data = await build(Object.assign({}, inputData)).then(screen);
|
|
450
|
-
const [transientFields] = destructure(defaultTransientFieldValues, inputData);
|
|
451
|
-
await handleBeforeCreate(data, transientFields);
|
|
452
|
-
const createdData = await getClient().authenticator.create({ data });
|
|
453
|
-
await handleAfterCreate(createdData, transientFields);
|
|
454
|
-
return createdData;
|
|
455
|
-
};
|
|
456
|
-
const createList = (...args) => Promise.all(normalizeList(...args).map(data => create(data)));
|
|
457
|
-
const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
|
|
458
|
-
return {
|
|
459
|
-
_factoryFor: "Authenticator",
|
|
460
|
-
build,
|
|
461
|
-
buildList,
|
|
462
|
-
buildCreateInput: build,
|
|
463
|
-
pickForConnect,
|
|
464
|
-
create,
|
|
465
|
-
createList,
|
|
466
|
-
createForConnect,
|
|
467
|
-
};
|
|
468
|
-
};
|
|
469
|
-
const factory = getFactoryWithTraits();
|
|
470
|
-
const useTraits = (name, ...names) => {
|
|
471
|
-
return getFactoryWithTraits([name, ...names]);
|
|
472
|
-
};
|
|
473
|
-
return Object.assign(Object.assign({}, factory), { use: useTraits });
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Define factory for {@link Authenticator} model.
|
|
477
|
-
*
|
|
478
|
-
* @param options
|
|
479
|
-
* @returns factory {@link AuthenticatorFactoryInterface}
|
|
480
|
-
*/
|
|
481
|
-
export const defineAuthenticatorFactory = ((options) => {
|
|
482
|
-
return defineAuthenticatorFactoryInternal(options, {});
|
|
483
|
-
});
|
|
484
|
-
defineAuthenticatorFactory.withTransientFields = defaultTransientFieldValues => options => defineAuthenticatorFactoryInternal(options, defaultTransientFieldValues);
|