alepha 0.20.2 → 0.20.3
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 +0 -1
- package/assets/swagger-ui/swagger-ui-bundle.js +1 -1
- package/assets/swagger-ui/swagger-ui.css +1 -1
- package/dist/api/audits/index.browser.js +49 -0
- package/dist/api/audits/index.browser.js.map +1 -1
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/audits/index.js +49 -0
- package/dist/api/audits/index.js.map +1 -1
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/jobs/index.d.ts +16 -75
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/jobs/index.js.map +1 -1
- package/dist/api/keys/index.js.map +1 -1
- package/dist/api/notifications/index.d.ts +1 -10
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/organizations/index.d.ts.map +1 -1
- package/dist/api/parameters/index.browser.js +37 -0
- package/dist/api/parameters/index.browser.js.map +1 -1
- package/dist/api/parameters/index.d.ts +4 -65
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/parameters/index.js +37 -0
- package/dist/api/parameters/index.js.map +1 -1
- package/dist/api/payments/index.d.ts.map +1 -1
- package/dist/api/payments/index.js.map +1 -1
- package/dist/api/users/index.d.ts +207 -5184
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/users/index.js +2 -4
- package/dist/api/users/index.js.map +1 -1
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/api/verifications/index.js +2 -1
- package/dist/api/verifications/index.js.map +1 -1
- package/dist/bucket/index.js +5 -1
- package/dist/bucket/index.js.map +1 -1
- package/dist/bucket/index.workerd.js +5 -1
- package/dist/bucket/index.workerd.js.map +1 -1
- package/dist/cache/core/index.js.map +1 -1
- package/dist/cache/core/index.workerd.js.map +1 -1
- package/dist/captcha/index.js.map +1 -1
- package/dist/cli/core/index.d.ts +217 -11647
- package/dist/cli/core/index.d.ts.map +1 -1
- package/dist/cli/core/index.js +706 -42
- package/dist/cli/core/index.js.map +1 -1
- package/dist/cli/devtools/index.js +7 -1
- package/dist/cli/devtools/index.js.map +1 -1
- package/dist/cli/platform/index.d.ts +41 -64
- package/dist/cli/platform/index.d.ts.map +1 -1
- package/dist/cli/platform/index.js +47 -0
- package/dist/cli/platform/index.js.map +1 -1
- package/dist/cli/vendor/index.js +15 -0
- package/dist/cli/vendor/index.js.map +1 -1
- package/dist/command/index.js +1 -1
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +2 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js.map +1 -1
- package/dist/core/index.workerd.js.map +1 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/datetime/index.js.map +1 -1
- package/dist/email/core/index.js.map +1 -1
- package/dist/email/smtp/index.js +2 -10522
- package/dist/email/smtp/index.js.map +1 -1
- package/dist/fake/index.d.ts +4 -8085
- package/dist/fake/index.d.ts.map +1 -1
- package/dist/fake/index.js +3 -33554
- package/dist/fake/index.js.map +1 -1
- package/dist/lock/core/index.js.map +1 -1
- package/dist/lock/redis/index.js.map +1 -1
- package/dist/logger/index.js +32 -1
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.js +5 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/core/index.browser.js +1 -361
- package/dist/orm/core/index.browser.js.map +1 -1
- package/dist/orm/core/index.bun.js +14 -406
- package/dist/orm/core/index.bun.js.map +1 -1
- package/dist/orm/core/index.d.ts +96 -5117
- package/dist/orm/core/index.d.ts.map +1 -1
- package/dist/orm/core/index.js +23 -419
- package/dist/orm/core/index.js.map +1 -1
- package/dist/orm/postgres/index.bun.js +17 -20
- package/dist/orm/postgres/index.bun.js.map +1 -1
- package/dist/orm/postgres/index.d.ts +2 -613
- package/dist/orm/postgres/index.d.ts.map +1 -1
- package/dist/orm/postgres/index.js +17 -20
- package/dist/orm/postgres/index.js.map +1 -1
- package/dist/react/core/index.js.map +1 -1
- package/dist/react/i18n/index.js.map +1 -1
- package/dist/react/intro/index.js +22 -17
- package/dist/react/intro/index.js.map +1 -1
- package/dist/react/router/index.browser.js +78 -2
- package/dist/react/router/index.browser.js.map +1 -1
- package/dist/react/router/index.d.ts +22 -1
- package/dist/react/router/index.d.ts.map +1 -1
- package/dist/react/router/index.js +102 -4
- package/dist/react/router/index.js.map +1 -1
- package/dist/react/testing/index.d.ts +1 -411
- package/dist/react/testing/index.d.ts.map +1 -1
- package/dist/react/testing/index.js +13 -12293
- package/dist/react/testing/index.js.map +1 -1
- package/dist/react/ui/index.js +3 -0
- package/dist/react/ui/index.js.map +1 -1
- package/dist/react/websocket/index.js.map +1 -1
- package/dist/redis/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +1 -83
- package/dist/scheduler/index.d.ts.map +1 -1
- package/dist/scheduler/index.js +2 -391
- package/dist/scheduler/index.js.map +1 -1
- package/dist/scheduler/index.workerd.js +2 -391
- package/dist/scheduler/index.workerd.js.map +1 -1
- package/dist/security/index.browser.js.map +1 -1
- package/dist/security/index.d.ts +2 -325
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +3 -1362
- package/dist/security/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +1 -1054
- package/dist/server/auth/index.d.ts.map +1 -1
- package/dist/server/auth/index.js +16 -1224
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/cookies/index.js.map +1 -1
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +1 -4
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +19 -4
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/links/index.browser.js.map +1 -1
- package/dist/server/links/index.js.map +1 -1
- package/dist/server/metrics/index.d.ts +1 -514
- package/dist/server/metrics/index.d.ts.map +1 -1
- package/dist/server/metrics/index.js +4 -4356
- package/dist/server/metrics/index.js.map +1 -1
- package/dist/server/rate-limit/index.js.map +1 -1
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.js +1 -1
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/sms/index.js.map +1 -1
- package/dist/system/index.browser.js.map +1 -1
- package/dist/system/index.js.map +1 -1
- package/dist/system/index.workerd.js.map +1 -1
- package/dist/topic/core/index.js.map +1 -1
- package/dist/websocket/index.browser.js +21 -0
- package/dist/websocket/index.browser.js.map +1 -1
- package/dist/websocket/index.js +21 -0
- package/dist/websocket/index.js.map +1 -1
- package/package.json +18 -15
- package/src/api/files/__tests__/FileController.spec.ts +1 -1
- package/src/api/jobs/__tests__/$job.spec.ts +5 -1
- package/src/api/users/schemas/userQuerySchema.ts +0 -1
- package/src/api/users/services/UserService.ts +1 -5
- package/src/api/verifications/__tests__/CodeVerification.spec.ts +14 -0
- package/src/api/verifications/__tests__/LinkVerification.spec.ts +14 -0
- package/src/api/verifications/services/VerificationService.ts +1 -0
- package/src/cli/core/__tests__/init.spec.ts +208 -0
- package/src/cli/core/commands/init.ts +12 -0
- package/src/cli/core/services/PackageManagerUtils.ts +23 -6
- package/src/cli/core/services/ProjectScaffolder.ts +298 -20
- package/src/cli/core/tasks/BuildDockerTask.ts +9 -10
- package/src/cli/core/tasks/BuildServerTask.ts +8 -0
- package/src/cli/core/templates/apiIndexTs.ts +23 -1
- package/src/cli/core/templates/componentsJsonTs.ts +39 -0
- package/src/cli/core/templates/mainCss.ts +1 -0
- package/src/cli/core/templates/saasAdminLayoutTsx.ts +77 -0
- package/src/cli/core/templates/saasAdminPagesTsx.ts +26 -0
- package/src/cli/core/templates/saasAuthLayoutTsx.ts +20 -0
- package/src/cli/core/templates/saasAuthPagesTsx.ts +62 -0
- package/src/cli/core/templates/saasRealmProviderTs.ts +46 -0
- package/src/cli/core/templates/webAppRouterTs.ts +104 -1
- package/src/cli/core/templates/webIndexTs.ts +23 -1
- package/src/cli/platform/__tests__/SecretsCommand.spec.ts +2 -0
- package/src/command/providers/CliProvider.ts +1 -1
- package/src/core/interfaces/Service.ts +3 -1
- package/src/core/providers/TypeProvider.ts +1 -1
- package/src/logger/services/Logger.ts +1 -1
- package/src/mcp/__tests__/$resource.spec.ts +1 -1
- package/src/mcp/__tests__/$tool.spec.ts +1 -1
- package/src/mcp/__tests__/McpServerProvider.spec.ts +1 -1
- package/src/orm/__tests__/$repository-tests.ts +1 -0
- package/src/orm/__tests__/orm-next-tests.ts +2 -67
- package/src/orm/__tests__/orm-next.spec.ts +0 -21
- package/src/orm/core/index.shared.ts +0 -2
- package/src/orm/core/index.ts +1 -2
- package/src/orm/core/primitives/$repository.ts +3 -6
- package/src/orm/core/providers/drivers/DatabaseProvider.ts +0 -5
- package/src/orm/core/providers/drivers/NodeSqliteProvider.ts +11 -13
- package/src/orm/core/services/ModelBuilder.ts +1 -13
- package/src/orm/core/services/Repository.ts +1 -42
- package/src/orm/core/services/SqliteModelBuilder.ts +2 -33
- package/src/orm/postgres/services/PostgresModelBuilder.ts +10 -45
- package/src/react/intro/components/GettingStartedAuthSlide.tsx +11 -4
- package/src/react/router/__tests__/ReactBrowserProvider.browser.spec.ts +213 -2
- package/src/react/router/providers/ReactBrowserProvider.ts +73 -0
- package/src/react/router/providers/ReactBrowserRouterProvider.ts +1 -1
- package/src/react/router/providers/ReactPreloadProvider.ts +1 -1
- package/src/react/router/providers/ReactServerProvider.ts +1 -0
- package/src/scheduler/providers/CronProvider.ts +1 -1
- package/src/security/primitives/$basicAuth.ts +1 -1
- package/src/server/auth/providers/ServerAuthProvider.ts +5 -1
- package/src/server/core/interfaces/ServerRequest.ts +1 -0
- package/src/server/core/providers/ServerProvider.ts +1 -1
- package/src/server/core/providers/ServerRouterProvider.ts +2 -2
- package/src/server/core/services/HttpClient.ts +1 -1
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
- package/dist/react/testing/chunk-DBEY4PJZ.js +0 -16
- package/src/orm/core/__tests__/parseQueryString.spec.ts +0 -196
- package/src/orm/core/helpers/parseQueryString.ts +0 -502
- package/src/orm/core/primitives/$view.ts +0 -88
|
@@ -291,314 +291,6 @@ var DbTableNotFoundError = class DbTableNotFoundError extends DbError {
|
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
293
|
//#endregion
|
|
294
|
-
//#region ../../src/orm/core/helpers/parseQueryString.ts
|
|
295
|
-
/**
|
|
296
|
-
* Parse a string query into a PgQueryWhere object.
|
|
297
|
-
*
|
|
298
|
-
* Supported syntax:
|
|
299
|
-
* - Simple equality: "name=John"
|
|
300
|
-
* - Wildcard patterns: "name=John*" (startsWith), "name=*John" (endsWith), "name=*John*" (contains)
|
|
301
|
-
* - Operators: "age>18", "age>=18", "age<65", "age<=65", "status!=active"
|
|
302
|
-
* - NULL checks: "deletedAt=null", "email!=null"
|
|
303
|
-
* - IN arrays: "status=[pending,active]"
|
|
304
|
-
* - AND conditions: "name=John&age>18"
|
|
305
|
-
* - OR conditions: "name=John|email=john@example.com"
|
|
306
|
-
* - Nested AND/OR: "(name=John|name=Jane)&age>18"
|
|
307
|
-
* - JSONB nested: "profile.city=Paris"
|
|
308
|
-
*
|
|
309
|
-
* @example
|
|
310
|
-
* ```ts
|
|
311
|
-
* // Simple equality
|
|
312
|
-
* parseQueryString("name=John")
|
|
313
|
-
* // => { name: { eq: "John" } }
|
|
314
|
-
*
|
|
315
|
-
* // Wildcard patterns
|
|
316
|
-
* parseQueryString("name=John*") // startsWith
|
|
317
|
-
* // => { name: { startsWith: "John" } }
|
|
318
|
-
* parseQueryString("name=*Smith") // endsWith
|
|
319
|
-
* // => { name: { endsWith: "Smith" } }
|
|
320
|
-
* parseQueryString("name=*oh*") // contains
|
|
321
|
-
* // => { name: { contains: "oh" } }
|
|
322
|
-
*
|
|
323
|
-
* // Multiple conditions
|
|
324
|
-
* parseQueryString("name=John&age>18")
|
|
325
|
-
* // => { and: [{ name: { eq: "John" } }, { age: { gt: 18 } }] }
|
|
326
|
-
*
|
|
327
|
-
* // OR conditions
|
|
328
|
-
* parseQueryString("status=active|status=pending")
|
|
329
|
-
* // => { or: [{ status: { eq: "active" } }, { status: { eq: "pending" } }] }
|
|
330
|
-
*
|
|
331
|
-
* // Complex nested
|
|
332
|
-
* parseQueryString("(name=John|name=Jane)&age>18&status!=archived")
|
|
333
|
-
* // => { and: [
|
|
334
|
-
* // { or: [{ name: { eq: "John" } }, { name: { eq: "Jane" } }] },
|
|
335
|
-
* // { age: { gt: 18 } },
|
|
336
|
-
* // { status: { ne: "archived" } }
|
|
337
|
-
* // ] }
|
|
338
|
-
*
|
|
339
|
-
* // JSONB nested query
|
|
340
|
-
* parseQueryString("profile.city=Paris&profile.age>25")
|
|
341
|
-
* // => { profile: { city: { eq: "Paris" }, age: { gt: 25 } } }
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
function parseQueryString(query) {
|
|
345
|
-
if (!query || query.trim() === "") return {};
|
|
346
|
-
return new QueryStringParser(query).parse();
|
|
347
|
-
}
|
|
348
|
-
var QueryStringParser = class {
|
|
349
|
-
pos = 0;
|
|
350
|
-
query;
|
|
351
|
-
constructor(query) {
|
|
352
|
-
this.query = query.trim();
|
|
353
|
-
}
|
|
354
|
-
parse() {
|
|
355
|
-
return this.parseExpression();
|
|
356
|
-
}
|
|
357
|
-
parseExpression() {
|
|
358
|
-
return this.parseOr();
|
|
359
|
-
}
|
|
360
|
-
parseOr() {
|
|
361
|
-
const left = this.parseAnd();
|
|
362
|
-
if (this.peek() === "|") {
|
|
363
|
-
const conditions = [left];
|
|
364
|
-
while (this.peek() === "|") {
|
|
365
|
-
this.consume("|");
|
|
366
|
-
conditions.push(this.parseAnd());
|
|
367
|
-
}
|
|
368
|
-
return { or: conditions };
|
|
369
|
-
}
|
|
370
|
-
return left;
|
|
371
|
-
}
|
|
372
|
-
parseAnd() {
|
|
373
|
-
const left = this.parsePrimary();
|
|
374
|
-
if (this.peek() === "&") {
|
|
375
|
-
const conditions = [left];
|
|
376
|
-
while (this.peek() === "&") {
|
|
377
|
-
this.consume("&");
|
|
378
|
-
conditions.push(this.parsePrimary());
|
|
379
|
-
}
|
|
380
|
-
return { and: conditions };
|
|
381
|
-
}
|
|
382
|
-
return left;
|
|
383
|
-
}
|
|
384
|
-
parsePrimary() {
|
|
385
|
-
this.skipWhitespace();
|
|
386
|
-
if (this.peek() === "(") {
|
|
387
|
-
this.consume("(");
|
|
388
|
-
const expr = this.parseExpression();
|
|
389
|
-
this.consume(")");
|
|
390
|
-
return expr;
|
|
391
|
-
}
|
|
392
|
-
return this.parseCondition();
|
|
393
|
-
}
|
|
394
|
-
parseCondition() {
|
|
395
|
-
const field = this.parseFieldPath();
|
|
396
|
-
this.skipWhitespace();
|
|
397
|
-
const operator = this.parseOperator();
|
|
398
|
-
this.skipWhitespace();
|
|
399
|
-
const value = this.parseValue();
|
|
400
|
-
if (value === "") throw new AlephaError(`Expected value for field '${field.join(".")}'`);
|
|
401
|
-
return this.buildCondition(field, operator, value);
|
|
402
|
-
}
|
|
403
|
-
parseFieldPath() {
|
|
404
|
-
const path = [];
|
|
405
|
-
let current = "";
|
|
406
|
-
while (this.pos < this.query.length) {
|
|
407
|
-
const ch = this.query[this.pos];
|
|
408
|
-
if (ch === "." && current) {
|
|
409
|
-
path.push(current);
|
|
410
|
-
current = "";
|
|
411
|
-
this.pos++;
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
if (ch === "=" || ch === "!" || ch === ">" || ch === "<" || ch === " ") break;
|
|
415
|
-
current += ch;
|
|
416
|
-
this.pos++;
|
|
417
|
-
}
|
|
418
|
-
if (current) path.push(current);
|
|
419
|
-
return path;
|
|
420
|
-
}
|
|
421
|
-
parseOperator() {
|
|
422
|
-
this.skipWhitespace();
|
|
423
|
-
const remaining = this.query.slice(this.pos);
|
|
424
|
-
if (remaining.startsWith(">=")) {
|
|
425
|
-
this.pos += 2;
|
|
426
|
-
return ">=";
|
|
427
|
-
}
|
|
428
|
-
if (remaining.startsWith("<=")) {
|
|
429
|
-
this.pos += 2;
|
|
430
|
-
return "<=";
|
|
431
|
-
}
|
|
432
|
-
if (remaining.startsWith("!=")) {
|
|
433
|
-
this.pos += 2;
|
|
434
|
-
return "!=";
|
|
435
|
-
}
|
|
436
|
-
const ch = this.query[this.pos];
|
|
437
|
-
if (ch === "=" || ch === ">" || ch === "<") {
|
|
438
|
-
this.pos++;
|
|
439
|
-
return ch;
|
|
440
|
-
}
|
|
441
|
-
throw new AlephaError(`Expected operator at position ${this.pos}`);
|
|
442
|
-
}
|
|
443
|
-
parseValue() {
|
|
444
|
-
this.skipWhitespace();
|
|
445
|
-
if (this.query.slice(this.pos, this.pos + 4).toLowerCase() === "null") {
|
|
446
|
-
this.pos += 4;
|
|
447
|
-
return null;
|
|
448
|
-
}
|
|
449
|
-
if (this.query[this.pos] === "[") return this.parseArray();
|
|
450
|
-
if (this.query[this.pos] === "\"" || this.query[this.pos] === "'") return this.parseQuotedString();
|
|
451
|
-
let value = "";
|
|
452
|
-
while (this.pos < this.query.length) {
|
|
453
|
-
const ch = this.query[this.pos];
|
|
454
|
-
if (ch === "&" || ch === "|" || ch === ")") break;
|
|
455
|
-
value += ch;
|
|
456
|
-
this.pos++;
|
|
457
|
-
}
|
|
458
|
-
return this.coerceValue(value.trim());
|
|
459
|
-
}
|
|
460
|
-
parseArray() {
|
|
461
|
-
this.consume("[");
|
|
462
|
-
const values = [];
|
|
463
|
-
while (this.pos < this.query.length && this.query[this.pos] !== "]") {
|
|
464
|
-
this.skipWhitespace();
|
|
465
|
-
if (this.query[this.pos] === "\"" || this.query[this.pos] === "'") values.push(this.parseQuotedString());
|
|
466
|
-
else {
|
|
467
|
-
let value = "";
|
|
468
|
-
while (this.pos < this.query.length && this.query[this.pos] !== "," && this.query[this.pos] !== "]") {
|
|
469
|
-
value += this.query[this.pos];
|
|
470
|
-
this.pos++;
|
|
471
|
-
}
|
|
472
|
-
values.push(this.coerceValue(value.trim()));
|
|
473
|
-
}
|
|
474
|
-
this.skipWhitespace();
|
|
475
|
-
if (this.query[this.pos] === ",") this.pos++;
|
|
476
|
-
}
|
|
477
|
-
this.consume("]");
|
|
478
|
-
return values;
|
|
479
|
-
}
|
|
480
|
-
parseQuotedString() {
|
|
481
|
-
const quote = this.query[this.pos];
|
|
482
|
-
this.pos++;
|
|
483
|
-
let value = "";
|
|
484
|
-
let escaped = false;
|
|
485
|
-
while (this.pos < this.query.length) {
|
|
486
|
-
const ch = this.query[this.pos];
|
|
487
|
-
if (escaped) {
|
|
488
|
-
value += ch;
|
|
489
|
-
escaped = false;
|
|
490
|
-
this.pos++;
|
|
491
|
-
continue;
|
|
492
|
-
}
|
|
493
|
-
if (ch === "\\") {
|
|
494
|
-
escaped = true;
|
|
495
|
-
this.pos++;
|
|
496
|
-
continue;
|
|
497
|
-
}
|
|
498
|
-
if (ch === quote) {
|
|
499
|
-
this.pos++;
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
value += ch;
|
|
503
|
-
this.pos++;
|
|
504
|
-
}
|
|
505
|
-
return value;
|
|
506
|
-
}
|
|
507
|
-
coerceValue(value) {
|
|
508
|
-
if (/^-?\d+$/.test(value)) return parseInt(value, 10);
|
|
509
|
-
if (/^-?\d+\.\d+$/.test(value)) return parseFloat(value);
|
|
510
|
-
if (value.toLowerCase() === "true") return true;
|
|
511
|
-
if (value.toLowerCase() === "false") return false;
|
|
512
|
-
return value;
|
|
513
|
-
}
|
|
514
|
-
buildCondition(path, operator, value) {
|
|
515
|
-
let filterOp;
|
|
516
|
-
if (operator === "=") if (value === null) filterOp = { isNull: true };
|
|
517
|
-
else if (Array.isArray(value)) filterOp = { inArray: value };
|
|
518
|
-
else if (typeof value === "string" && value.includes("*")) {
|
|
519
|
-
const startsWithAsterisk = value.startsWith("*");
|
|
520
|
-
const endsWithAsterisk = value.endsWith("*");
|
|
521
|
-
const cleanValue = value.replace(/^\*|\*$/g, "");
|
|
522
|
-
if (startsWithAsterisk && endsWithAsterisk) filterOp = { contains: cleanValue };
|
|
523
|
-
else if (startsWithAsterisk) filterOp = { endsWith: cleanValue };
|
|
524
|
-
else if (endsWithAsterisk) filterOp = { startsWith: cleanValue };
|
|
525
|
-
else filterOp = { eq: value };
|
|
526
|
-
} else filterOp = { eq: value };
|
|
527
|
-
else if (operator === "!=") if (value === null) filterOp = { isNotNull: true };
|
|
528
|
-
else filterOp = { ne: value };
|
|
529
|
-
else if (operator === ">") filterOp = { gt: value };
|
|
530
|
-
else if (operator === ">=") filterOp = { gte: value };
|
|
531
|
-
else if (operator === "<") filterOp = { lt: value };
|
|
532
|
-
else if (operator === "<=") filterOp = { lte: value };
|
|
533
|
-
else throw new AlephaError(`Unsupported operator: ${operator}`);
|
|
534
|
-
if (path.length === 1) return { [path[0]]: filterOp };
|
|
535
|
-
let result = filterOp;
|
|
536
|
-
for (let i = path.length - 1; i >= 0; i--) result = { [path[i]]: result };
|
|
537
|
-
return result;
|
|
538
|
-
}
|
|
539
|
-
peek() {
|
|
540
|
-
this.skipWhitespace();
|
|
541
|
-
return this.query[this.pos] || "";
|
|
542
|
-
}
|
|
543
|
-
consume(expected) {
|
|
544
|
-
this.skipWhitespace();
|
|
545
|
-
if (this.query[this.pos] !== expected) throw new AlephaError(`Expected '${expected}' at position ${this.pos}, got '${this.query[this.pos]}'`);
|
|
546
|
-
this.pos++;
|
|
547
|
-
}
|
|
548
|
-
skipWhitespace() {
|
|
549
|
-
while (this.pos < this.query.length && /\s/.test(this.query[this.pos])) this.pos++;
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
/**
|
|
553
|
-
* Helper function to build query strings programmatically
|
|
554
|
-
*
|
|
555
|
-
* @example
|
|
556
|
-
* ```ts
|
|
557
|
-
* buildQueryString({
|
|
558
|
-
* and: [
|
|
559
|
-
* { name: "eq:John" },
|
|
560
|
-
* { age: "gt:18" }
|
|
561
|
-
* ]
|
|
562
|
-
* })
|
|
563
|
-
* // => "name=John&age>18"
|
|
564
|
-
* ```
|
|
565
|
-
*/
|
|
566
|
-
function buildQueryString(where) {
|
|
567
|
-
if (!where || typeof where !== "object") return "";
|
|
568
|
-
if ("and" in where && Array.isArray(where.and)) return where.and.map((w) => buildQueryString(w)).join("&");
|
|
569
|
-
if ("or" in where && Array.isArray(where.or)) {
|
|
570
|
-
const parts = where.or.map((w) => buildQueryString(w));
|
|
571
|
-
return parts.length > 1 ? `(${parts.join("|")})` : parts[0];
|
|
572
|
-
}
|
|
573
|
-
if ("not" in where) return "";
|
|
574
|
-
const parts = [];
|
|
575
|
-
for (const [field, condition] of Object.entries(where)) {
|
|
576
|
-
if (typeof condition !== "object" || condition === null) {
|
|
577
|
-
parts.push(`${field}=${condition}`);
|
|
578
|
-
continue;
|
|
579
|
-
}
|
|
580
|
-
if ("eq" in condition) parts.push(`${field}=${condition.eq}`);
|
|
581
|
-
else if ("ne" in condition) parts.push(`${field}!=${condition.ne}`);
|
|
582
|
-
else if ("gt" in condition) parts.push(`${field}>${condition.gt}`);
|
|
583
|
-
else if ("gte" in condition) parts.push(`${field}>=${condition.gte}`);
|
|
584
|
-
else if ("lt" in condition) parts.push(`${field}<${condition.lt}`);
|
|
585
|
-
else if ("lte" in condition) parts.push(`${field}<=${condition.lte}`);
|
|
586
|
-
else if ("contains" in condition) parts.push(`${field}=*${condition.contains}*`);
|
|
587
|
-
else if ("startsWith" in condition) parts.push(`${field}=${condition.startsWith}*`);
|
|
588
|
-
else if ("endsWith" in condition) parts.push(`${field}=*${condition.endsWith}`);
|
|
589
|
-
else if ("isNull" in condition && condition.isNull) parts.push(`${field}=null`);
|
|
590
|
-
else if ("isNotNull" in condition && condition.isNotNull) parts.push(`${field}!=null`);
|
|
591
|
-
else if ("inArray" in condition && Array.isArray(condition.inArray)) {
|
|
592
|
-
const values = condition.inArray.map((v) => typeof v === "string" ? `"${v}"` : v);
|
|
593
|
-
parts.push(`${field}=[${values.join(",")}]`);
|
|
594
|
-
} else {
|
|
595
|
-
const nested = buildQueryString(condition);
|
|
596
|
-
if (nested) parts.push(`${field}.${nested}`);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
return parts.join("&");
|
|
600
|
-
}
|
|
601
|
-
//#endregion
|
|
602
294
|
//#region ../../src/orm/core/helpers/pgAttr.ts
|
|
603
295
|
/**
|
|
604
296
|
* Decorates a typebox schema with a Postgres attribute.
|
|
@@ -732,58 +424,6 @@ var EntityPrimitive = class EntityPrimitive {
|
|
|
732
424
|
};
|
|
733
425
|
$entity[KIND] = EntityPrimitive;
|
|
734
426
|
//#endregion
|
|
735
|
-
//#region ../../src/orm/core/primitives/$view.ts
|
|
736
|
-
/**
|
|
737
|
-
* Creates a database view primitive from a TypeBox schema and SQL query.
|
|
738
|
-
*
|
|
739
|
-
* Views are read-only: Repository blocks all write operations.
|
|
740
|
-
*
|
|
741
|
-
* @example
|
|
742
|
-
* ```ts
|
|
743
|
-
* import { t } from "alepha";
|
|
744
|
-
* import { $view } from "alepha/orm";
|
|
745
|
-
* import { sql } from "drizzle-orm";
|
|
746
|
-
*
|
|
747
|
-
* const userSummary = $view({
|
|
748
|
-
* name: "user_summary",
|
|
749
|
-
* schema: t.object({
|
|
750
|
-
* id: t.uuid(),
|
|
751
|
-
* fullName: t.text(),
|
|
752
|
-
* orderCount: t.integer(),
|
|
753
|
-
* }),
|
|
754
|
-
* query: sql`SELECT u.id, u.first_name || ' ' || u.last_name AS full_name, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON o.user_id = u.id GROUP BY u.id`,
|
|
755
|
-
* });
|
|
756
|
-
*
|
|
757
|
-
* // Materialized view (PostgreSQL only)
|
|
758
|
-
* const monthlyStats = $view({
|
|
759
|
-
* name: "monthly_stats",
|
|
760
|
-
* schema: t.object({ ... }),
|
|
761
|
-
* query: sql`...`,
|
|
762
|
-
* materialized: true,
|
|
763
|
-
* });
|
|
764
|
-
* ```
|
|
765
|
-
*/
|
|
766
|
-
const $view = (options) => {
|
|
767
|
-
return new ViewPrimitive(options);
|
|
768
|
-
};
|
|
769
|
-
var ViewPrimitive = class {
|
|
770
|
-
options;
|
|
771
|
-
isView = true;
|
|
772
|
-
constructor(options) {
|
|
773
|
-
this.options = options;
|
|
774
|
-
}
|
|
775
|
-
get name() {
|
|
776
|
-
return this.options.name;
|
|
777
|
-
}
|
|
778
|
-
get schema() {
|
|
779
|
-
return this.options.schema;
|
|
780
|
-
}
|
|
781
|
-
get materialized() {
|
|
782
|
-
return this.options.materialized ?? false;
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
$view[KIND] = ViewPrimitive;
|
|
786
|
-
//#endregion
|
|
787
427
|
//#region ../../src/orm/core/providers/DatabaseTypeProvider.ts
|
|
788
428
|
var DatabaseTypeProvider = class {
|
|
789
429
|
attr = pgAttr;
|
|
@@ -897,6 +537,6 @@ const AlephaOrm = $module({
|
|
|
897
537
|
services: [AlephaDateTime]
|
|
898
538
|
});
|
|
899
539
|
//#endregion
|
|
900
|
-
export { $entity,
|
|
540
|
+
export { $entity, AlephaOrm, DatabaseTypeProvider, DbColumnNotFoundError, DbConnectionError, DbDeadlockError, DbEntityNotFoundError, DbForeignKeyError, DbNotNullError, DbTableNotFoundError, EntityPrimitive, db, getAttrFields, legacyIdSchema, pageQuerySchema, pageSchema, pgAttr, sql };
|
|
901
541
|
|
|
902
542
|
//# sourceMappingURL=index.browser.js.map
|