create-erxes 0.1.13 → 0.1.14
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/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { mkdir, readFile, readdir, symlink, writeFile } from "node:fs/promises";
|
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
// package.json
|
|
12
|
-
var version = "0.1.
|
|
12
|
+
var version = "0.1.14";
|
|
13
13
|
// src/existing-plugins.ts
|
|
14
14
|
/** The old erxes plugins a new-core plugin can be migrated from (`backend/plugins/<name>_api`). */
|
|
15
15
|
const OLD_PLUGINS = [
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"db:check": "drizzle-kit check"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@erxes/core-contract": "0.1.0-v2.
|
|
25
|
-
"@erxes/plugin-sdk": "0.1.0-v2.
|
|
24
|
+
"@erxes/core-contract": "0.1.0-v2.12",
|
|
25
|
+
"@erxes/plugin-sdk": "0.1.0-v2.11",
|
|
26
26
|
"@opentelemetry/instrumentation-express": "^0.73.0",
|
|
27
27
|
"@opentelemetry/instrumentation-http": "^0.301.1",
|
|
28
28
|
"@opentelemetry/instrumentation-pg": "^0.78.0",
|
|
@@ -210,15 +210,15 @@ for (const call of inventory.trpcCalls) {
|
|
|
210
210
|
if (equivalent === OWN_TEAMS) usesTeams = true;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
// Old core's structure:
|
|
214
|
-
//
|
|
213
|
+
// Old core's structure: core's units, imported with their Mongo ids, so the ids the plugin's
|
|
214
|
+
// records hold stay valid; the plugin queries its copy.
|
|
215
215
|
for (const schema of inventory.schemas) {
|
|
216
216
|
for (const field of schema.fields.filter((entry) => isStructureField(entry.name))) {
|
|
217
217
|
usesTeams = true;
|
|
218
218
|
add(
|
|
219
219
|
schema.module,
|
|
220
220
|
'Tables',
|
|
221
|
-
`\`${schema.name}.${field.name}\` →
|
|
221
|
+
`\`${schema.name}.${field.name}\` → core unit ids (copy in \`${TEAMS}\`), unchanged by the import ${at(schema)}`,
|
|
222
222
|
OWN_TEAMS.kind,
|
|
223
223
|
);
|
|
224
224
|
}
|
|
@@ -228,7 +228,7 @@ if (usesTeams) {
|
|
|
228
228
|
add(
|
|
229
229
|
'(plugin)',
|
|
230
230
|
'Tables',
|
|
231
|
-
`\`${TEAMS}\` and \`${TEAM_MEMBERS}
|
|
231
|
+
`\`${TEAMS}\` and \`${TEAM_MEMBERS}\`: a read-only copy of core's units (drafts in migration/schema-draft.ts). scripts/import-mongo.ts fills it from old core's \`departments\`, \`branches\` and the members' \`departmentIds\` and \`branchIds\`; push it to core once with \`units.import\`, then refresh it on \`core.unit.*\` events (scopes \`units:read\`, \`units:write\`; subscription \`core.unit.*\`)`,
|
|
232
232
|
OWN_TEAMS.kind,
|
|
233
233
|
);
|
|
234
234
|
}
|
|
@@ -457,7 +457,7 @@ for (const collection of inventory.collections) {
|
|
|
457
457
|
if (usesTeams) {
|
|
458
458
|
tables.push(
|
|
459
459
|
[
|
|
460
|
-
"/**
|
|
460
|
+
"/** A read-only copy of core's branches and departments. Imported ones keep the Mongo `_id`s. */",
|
|
461
461
|
`export const ${camel(TEAMS)} = table(`,
|
|
462
462
|
" 'teams',",
|
|
463
463
|
' {',
|
|
@@ -23,17 +23,18 @@ const gap = (note: string): Equivalent => ({ kind: 'gap', to: '', note });
|
|
|
23
23
|
const drop = (note: string): Equivalent => ({ kind: 'drop', to: '', note });
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* Old core's structure (departments, branches, units
|
|
27
|
-
* used it keeps its own
|
|
26
|
+
* Old core's structure (departments, branches, units): core's `units` (decision 43). A plugin
|
|
27
|
+
* that used it keeps a read-only copy for its own queries; migration/checklist.ts drafts the
|
|
28
|
+
* copy's tables and the import. Positions are HR's.
|
|
28
29
|
*/
|
|
29
|
-
export const OWN_TEAMS =
|
|
30
|
-
'
|
|
31
|
-
"
|
|
30
|
+
export const OWN_TEAMS = contract(
|
|
31
|
+
'units.list',
|
|
32
|
+
"units:read; a read-only copy in <plugin>_teams and <plugin>_team_members, refreshed on core.unit.* events, for the plugin's own visibility queries. Old units go to core once with units.import (units:write), keeping their ids",
|
|
32
33
|
);
|
|
33
34
|
|
|
34
|
-
/** A field holding old
|
|
35
|
+
/** A field holding old unit ids or switches: `departmentIds`, `branchId`, `isCheckBranch`. */
|
|
35
36
|
export const isStructureField = (name: string) =>
|
|
36
|
-
/^(department|branch|unit
|
|
37
|
+
/^(department|branch|unit)Ids?$|^isCheck(Department|Branch)$/.test(name);
|
|
37
38
|
|
|
38
39
|
const NO_SEGMENTS = drop('the new core has no segments; the plugin filters its own records');
|
|
39
40
|
|
|
@@ -47,7 +48,7 @@ export const WHOLE_MODULES: Record<string, Equivalent> = {
|
|
|
47
48
|
branches: OWN_TEAMS,
|
|
48
49
|
departments: OWN_TEAMS,
|
|
49
50
|
units: OWN_TEAMS,
|
|
50
|
-
positions:
|
|
51
|
+
positions: drop("positions are the HR plugin's; other plugins leave them out"),
|
|
51
52
|
brands: drop('the new core has no brands; leave brand ids and names out'),
|
|
52
53
|
clientPortal: CLIENT_PORTAL,
|
|
53
54
|
clientPortals: CLIENT_PORTAL,
|