@yongdall/migrate 0.5.0 → 0.5.2

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/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { connect } from "@yongdall/connection";
1
+ import { useDatabase } from "@yongdall/connection";
2
2
  import { _run } from "@yongdall/context";
3
3
  import { loadPluginProfiles } from "@yongdall/plugins";
4
4
 
@@ -29,13 +29,13 @@ async function migrate_default({ plugins, database, domain } = {}) {
29
29
  if (typeof database === "string") {
30
30
  const id = ["-_/"].includes(database) ? "" : database;
31
31
  const models = modelList.filter((v) => (v.databaseId || "") === id);
32
- await connect("rdb", id).transaction((t) => t.syncTables(models));
32
+ await useDatabase(id).transaction((t) => t.syncTables(models));
33
33
  return;
34
34
  }
35
35
  const models = Object.groupBy(modelList, (d) => d.databaseId || "");
36
36
  for (const [databaseId, list] of Object.entries(models)) {
37
37
  if (!list) continue;
38
- await connect("rdb", databaseId).transaction((t) => t.syncTables(list));
38
+ await useDatabase(databaseId).transaction((t) => t.syncTables(list));
39
39
  }
40
40
  });
41
41
  }
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../cli/migrate/index.mjs"],"sourcesContent":["/** @import { ModelTable } from '@yongdall/model' */\nimport { connect } from '@yongdall/connection';\nimport { _run } from '@yongdall/context';\nimport { loadPluginProfiles } from '@yongdall/plugins';\n\n/**\n * @typedef {object} Profile\n * @property {ModelTable[]} models\n */\n/**\n * \n * @param {object} [options]\n * @param {string[]} [options.plugins]\n * @param {string} [options.database] \n * @param {string} [options.domain] \n * @returns {Promise<void>}\n */\nexport default async function ({\n\tplugins, database, domain\n} = {}) {\n\tconst pluginSet = plugins?.length ? new Set(plugins) : null;\n\tconst modelList = await Array.fromAsync(\n\t\tloadPluginProfiles('migration', function* (/** @type {Partial<Profile>} */config, plugin) {\n\t\t\tif (!config) { return; }\n\t\t\tif (pluginSet && !pluginSet.has(plugin)) { return; }\n\t\t\tconst models = config.models;\n\t\t\tif (!Array.isArray(models)) { return; }\n\t\t\tyield* models;\n\t\t})\n\t);\n\treturn _run({ domain: domain || '' }, async () => {\n\t\tif (typeof database === 'string') {\n\t\t\tconst id = ['-_/'].includes(database) ? '' : database;\n\t\t\tconst models = modelList.filter(v => (v.databaseId || '') === id);\n\t\t\tawait connect('rdb', id).transaction(t => t.syncTables(models));\n\t\t\treturn;\n\t\t}\n\t\tconst models = Object.groupBy(modelList, d => d.databaseId || '');\n\t\tfor (const [databaseId, list] of Object.entries(models)) {\n\t\t\tif (!list) { continue; }\n\t\t\tawait connect('rdb', databaseId).transaction(t => t.syncTables(list));\n\t\t}\n\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,+BAA+B,EAC9B,SAAS,UAAU,WAChB,EAAE,EAAE;CACP,MAAM,YAAY,SAAS,SAAS,IAAI,IAAI,QAAQ,GAAG;CACvD,MAAM,YAAY,MAAM,MAAM,UAC7B,mBAAmB,aAAa,WAA0C,QAAQ,QAAQ;AACzF,MAAI,CAAC,OAAU;AACf,MAAI,aAAa,CAAC,UAAU,IAAI,OAAO,CAAI;EAC3C,MAAM,SAAS,OAAO;AACtB,MAAI,CAAC,MAAM,QAAQ,OAAO,CAAI;AAC9B,SAAO;GACN,CACF;AACD,QAAO,KAAK,EAAE,QAAQ,UAAU,IAAI,EAAE,YAAY;AACjD,MAAI,OAAO,aAAa,UAAU;GACjC,MAAM,KAAK,CAAC,MAAM,CAAC,SAAS,SAAS,GAAG,KAAK;GAC7C,MAAM,SAAS,UAAU,QAAO,OAAM,EAAE,cAAc,QAAQ,GAAG;AACjE,SAAM,QAAQ,OAAO,GAAG,CAAC,aAAY,MAAK,EAAE,WAAW,OAAO,CAAC;AAC/D;;EAED,MAAM,SAAS,OAAO,QAAQ,YAAW,MAAK,EAAE,cAAc,GAAG;AACjE,OAAK,MAAM,CAAC,YAAY,SAAS,OAAO,QAAQ,OAAO,EAAE;AACxD,OAAI,CAAC,KAAQ;AACb,SAAM,QAAQ,OAAO,WAAW,CAAC,aAAY,MAAK,EAAE,WAAW,KAAK,CAAC;;GAGrE"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../cli/migrate/index.mjs"],"sourcesContent":["/** @import { ModelTable } from '@yongdall/model' */\nimport { useDatabase } from '@yongdall/connection';\nimport { _run } from '@yongdall/context';\nimport { loadPluginProfiles } from '@yongdall/plugins';\n\n/**\n * @typedef {object} Profile\n * @property {ModelTable[]} models\n */\n/**\n * \n * @param {object} [options]\n * @param {string[]} [options.plugins]\n * @param {string} [options.database] \n * @param {string} [options.domain] \n * @returns {Promise<void>}\n */\nexport default async function ({\n\tplugins, database, domain\n} = {}) {\n\tconst pluginSet = plugins?.length ? new Set(plugins) : null;\n\tconst modelList = await Array.fromAsync(\n\t\tloadPluginProfiles('migration', function* (/** @type {Partial<Profile>} */config, plugin) {\n\t\t\tif (!config) { return; }\n\t\t\tif (pluginSet && !pluginSet.has(plugin)) { return; }\n\t\t\tconst models = config.models;\n\t\t\tif (!Array.isArray(models)) { return; }\n\t\t\tyield* models;\n\t\t})\n\t);\n\treturn _run({ domain: domain || '' }, async () => {\n\t\tif (typeof database === 'string') {\n\t\t\tconst id = ['-_/'].includes(database) ? '' : database;\n\t\t\tconst models = modelList.filter(v => (v.databaseId || '') === id);\n\t\t\tawait useDatabase(id).transaction(t => t.syncTables(models));\n\t\t\treturn;\n\t\t}\n\t\tconst models = Object.groupBy(modelList, d => d.databaseId || '');\n\t\tfor (const [databaseId, list] of Object.entries(models)) {\n\t\t\tif (!list) { continue; }\n\t\t\tawait useDatabase(databaseId).transaction(t => t.syncTables(list));\n\t\t}\n\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,+BAA+B,EAC9B,SAAS,UAAU,WAChB,EAAE,EAAE;CACP,MAAM,YAAY,SAAS,SAAS,IAAI,IAAI,QAAQ,GAAG;CACvD,MAAM,YAAY,MAAM,MAAM,UAC7B,mBAAmB,aAAa,WAA0C,QAAQ,QAAQ;AACzF,MAAI,CAAC,OAAU;AACf,MAAI,aAAa,CAAC,UAAU,IAAI,OAAO,CAAI;EAC3C,MAAM,SAAS,OAAO;AACtB,MAAI,CAAC,MAAM,QAAQ,OAAO,CAAI;AAC9B,SAAO;GACN,CACF;AACD,QAAO,KAAK,EAAE,QAAQ,UAAU,IAAI,EAAE,YAAY;AACjD,MAAI,OAAO,aAAa,UAAU;GACjC,MAAM,KAAK,CAAC,MAAM,CAAC,SAAS,SAAS,GAAG,KAAK;GAC7C,MAAM,SAAS,UAAU,QAAO,OAAM,EAAE,cAAc,QAAQ,GAAG;AACjE,SAAM,YAAY,GAAG,CAAC,aAAY,MAAK,EAAE,WAAW,OAAO,CAAC;AAC5D;;EAED,MAAM,SAAS,OAAO,QAAQ,YAAW,MAAK,EAAE,cAAc,GAAG;AACjE,OAAK,MAAM,CAAC,YAAY,SAAS,OAAO,QAAQ,OAAO,EAAE;AACxD,OAAI,CAAC,KAAQ;AACb,SAAM,YAAY,WAAW,CAAC,aAAY,MAAK,EAAE,WAAW,KAAK,CAAC;;GAGlE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yongdall/migrate",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "main": "./index.mjs",
6
6
  "imports": {