@loomcore/api 0.1.97 → 0.1.99

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 (37) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +77 -77
  3. package/dist/__tests__/common-test.utils.js +3 -5
  4. package/dist/__tests__/postgres-test-migrations/postgres-test-schema.js +266 -266
  5. package/dist/__tests__/postgres.test-database.js +8 -8
  6. package/dist/databases/migrations/migration-runner.js +21 -21
  7. package/dist/databases/mongo-db/utils/convert-operations-to-pipeline.util.js +65 -473
  8. package/dist/databases/operations/index.d.ts +3 -4
  9. package/dist/databases/operations/index.js +3 -4
  10. package/dist/databases/operations/{join.operation.d.ts → inner-join.operation.d.ts} +1 -1
  11. package/dist/databases/operations/{join.operation.js → inner-join.operation.js} +2 -2
  12. package/dist/databases/operations/left-join-many.operation.d.ts +7 -0
  13. package/dist/databases/operations/left-join-many.operation.js +15 -0
  14. package/dist/databases/operations/{join-many.operation.d.ts → left-join.operation.d.ts} +1 -1
  15. package/dist/databases/operations/{join-many.operation.js → left-join.operation.js} +2 -2
  16. package/dist/databases/operations/operation.d.ts +4 -5
  17. package/dist/databases/postgres/commands/postgres-batch-update.command.js +11 -12
  18. package/dist/databases/postgres/commands/postgres-create-many.command.js +4 -4
  19. package/dist/databases/postgres/commands/postgres-create.command.js +4 -4
  20. package/dist/databases/postgres/commands/postgres-full-update-by-id.command.js +14 -14
  21. package/dist/databases/postgres/commands/postgres-partial-update-by-id.command.js +8 -8
  22. package/dist/databases/postgres/commands/postgres-update.command.js +8 -8
  23. package/dist/databases/postgres/migrations/postgres-initial-schema.js +224 -224
  24. package/dist/databases/postgres/postgres.database.js +17 -17
  25. package/dist/databases/postgres/queries/postgres-get-all.query.js +4 -5
  26. package/dist/databases/postgres/queries/postgres-get-by-id.query.js +4 -5
  27. package/dist/databases/postgres/queries/postgres-get.query.js +4 -5
  28. package/dist/databases/postgres/utils/build-join-clauses.d.ts +1 -1
  29. package/dist/databases/postgres/utils/build-join-clauses.js +26 -360
  30. package/dist/databases/postgres/utils/build-select-clause.js +15 -27
  31. package/dist/databases/postgres/utils/does-table-exist.util.js +4 -4
  32. package/dist/databases/postgres/utils/transform-join-results.js +19 -120
  33. package/package.json +92 -92
  34. package/dist/databases/operations/join-through-many.operation.d.ts +0 -10
  35. package/dist/databases/operations/join-through-many.operation.js +0 -21
  36. package/dist/databases/operations/join-through.operation.d.ts +0 -10
  37. package/dist/databases/operations/join-through.operation.js +0 -21
@@ -78,9 +78,9 @@ export class TestPostgresDatabase {
78
78
  }
79
79
  async createIndexes(client) {
80
80
  try {
81
- await client.query(`
82
- CREATE INDEX IF NOT EXISTS email_index ON users (LOWER(email));
83
- CREATE UNIQUE INDEX IF NOT EXISTS email_unique_index ON users (LOWER(email));
81
+ await client.query(`
82
+ CREATE INDEX IF NOT EXISTS email_index ON users (LOWER(email));
83
+ CREATE UNIQUE INDEX IF NOT EXISTS email_unique_index ON users (LOWER(email));
84
84
  `);
85
85
  }
86
86
  catch (error) {
@@ -91,11 +91,11 @@ export class TestPostgresDatabase {
91
91
  if (!this.postgresClient) {
92
92
  throw new Error('Database not initialized');
93
93
  }
94
- const result = await this.postgresClient.query(`
95
- SELECT "table_name"
96
- FROM information_schema.tables
97
- WHERE "table_schema" = 'public'
98
- AND "table_type" = 'BASE TABLE'
94
+ const result = await this.postgresClient.query(`
95
+ SELECT "table_name"
96
+ FROM information_schema.tables
97
+ WHERE "table_schema" = 'public'
98
+ AND "table_type" = 'BASE TABLE'
99
99
  `);
100
100
  result.rows.forEach(async (row) => {
101
101
  await this.postgresClient?.query(`TRUNCATE TABLE "${row.table_name}" RESTART IDENTITY CASCADE`);
@@ -252,31 +252,31 @@ export class MigrationRunner {
252
252
  let content = '';
253
253
  if (this.dbType === 'postgres') {
254
254
  extension = 'sql';
255
- content = `-- Migration: ${safeName}
256
- -- Created: ${new Date().toISOString()}
257
-
258
- -- up
259
- -- Write your CREATE/ALTER statements here...
260
-
261
-
262
- -- down
263
- -- Write your DROP/UNDO statements here...
255
+ content = `-- Migration: ${safeName}
256
+ -- Created: ${new Date().toISOString()}
257
+
258
+ -- up
259
+ -- Write your CREATE/ALTER statements here...
260
+
261
+
262
+ -- down
263
+ -- Write your DROP/UNDO statements here...
264
264
  `;
265
265
  }
266
266
  else {
267
267
  extension = 'ts';
268
- content = `import { Db } from 'mongodb';
269
-
270
- // Migration: ${safeName}
271
- // Created: ${new Date().toISOString()}
272
-
273
- export const up = async ({ context: db }: { context: Db }) => {
274
- // await db.collection('...')....
275
- };
276
-
277
- export const down = async ({ context: db }: { context: Db }) => {
278
- // await db.collection('...')....
279
- };
268
+ content = `import { Db } from 'mongodb';
269
+
270
+ // Migration: ${safeName}
271
+ // Created: ${new Date().toISOString()}
272
+
273
+ export const up = async ({ context: db }: { context: Db }) => {
274
+ // await db.collection('...')....
275
+ };
276
+
277
+ export const down = async ({ context: db }: { context: Db }) => {
278
+ // await db.collection('...')....
279
+ };
280
280
  `;
281
281
  }
282
282
  const fullPath = path.join(this.migrationsDir, `${filename}.${extension}`);