@open-mercato/core 0.4.2-canary-1b99a1211d → 0.4.2-canary-f6b7824b47
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/modules/api_docs/backend/docs/page.js +1 -4
- package/dist/modules/api_docs/backend/docs/page.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +0 -4
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/sales/acl.js +1 -3
- package/dist/modules/sales/acl.js.map +2 -2
- package/package.json +2 -2
- package/src/modules/api_docs/backend/docs/page.tsx +1 -2
- package/src/modules/auth/lib/setup-app.ts +0 -4
- package/src/modules/customers/README.md +1 -2
- package/src/modules/entities/README.md +1 -1
- package/src/modules/sales/acl.ts +0 -2
- package/src/modules/sales/i18n/de.json +1 -32
- package/src/modules/sales/i18n/en.json +1 -32
- package/src/modules/sales/i18n/es.json +1 -32
- package/src/modules/sales/i18n/pl.json +1 -32
- package/dist/modules/sales/api/dashboard/widgets/new-orders/route.js +0 -163
- package/dist/modules/sales/api/dashboard/widgets/new-orders/route.js.map +0 -7
- package/dist/modules/sales/api/dashboard/widgets/new-quotes/route.js +0 -165
- package/dist/modules/sales/api/dashboard/widgets/new-quotes/route.js.map +0 -7
- package/dist/modules/sales/api/dashboard/widgets/utils.js +0 -38
- package/dist/modules/sales/api/dashboard/widgets/utils.js.map +0 -7
- package/dist/modules/sales/lib/customerSnapshot.js +0 -21
- package/dist/modules/sales/lib/customerSnapshot.js.map +0 -7
- package/dist/modules/sales/lib/dateRange.js +0 -39
- package/dist/modules/sales/lib/dateRange.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-orders/config.js +0 -41
- package/dist/modules/sales/widgets/dashboard/new-orders/config.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js +0 -252
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.client.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.js +0 -33
- package/dist/modules/sales/widgets/dashboard/new-orders/widget.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-quotes/config.js +0 -41
- package/dist/modules/sales/widgets/dashboard/new-quotes/config.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js +0 -272
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.client.js.map +0 -7
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.js +0 -33
- package/dist/modules/sales/widgets/dashboard/new-quotes/widget.js.map +0 -7
- package/src/modules/sales/api/dashboard/widgets/new-orders/__tests__/route.test.ts +0 -60
- package/src/modules/sales/api/dashboard/widgets/new-orders/route.ts +0 -192
- package/src/modules/sales/api/dashboard/widgets/new-quotes/__tests__/route.test.ts +0 -61
- package/src/modules/sales/api/dashboard/widgets/new-quotes/route.ts +0 -194
- package/src/modules/sales/api/dashboard/widgets/utils.ts +0 -53
- package/src/modules/sales/lib/__tests__/dateRange.test.ts +0 -26
- package/src/modules/sales/lib/customerSnapshot.ts +0 -17
- package/src/modules/sales/lib/dateRange.ts +0 -42
- package/src/modules/sales/widgets/dashboard/new-orders/__tests__/config.test.ts +0 -28
- package/src/modules/sales/widgets/dashboard/new-orders/config.ts +0 -55
- package/src/modules/sales/widgets/dashboard/new-orders/widget.client.tsx +0 -295
- package/src/modules/sales/widgets/dashboard/new-orders/widget.ts +0 -33
- package/src/modules/sales/widgets/dashboard/new-quotes/__tests__/config.test.ts +0 -28
- package/src/modules/sales/widgets/dashboard/new-quotes/config.ts +0 -55
- package/src/modules/sales/widgets/dashboard/new-quotes/widget.client.tsx +0 -322
- package/src/modules/sales/widgets/dashboard/new-quotes/widget.ts +0 -33
|
@@ -32,10 +32,7 @@ async function ApiDocsPage() {
|
|
|
32
32
|
] }),
|
|
33
33
|
/* @__PURE__ */ jsxs("p", { children: [
|
|
34
34
|
"Run ",
|
|
35
|
-
/* @__PURE__ */ jsx("code", { className: "rounded bg-background px-2 py-0.5 text-xs text-foreground", children: "
|
|
36
|
-
" ",
|
|
37
|
-
"then ",
|
|
38
|
-
/* @__PURE__ */ jsx("code", { className: "rounded bg-background px-2 py-0.5 text-xs text-foreground", children: "yarn generate" }),
|
|
35
|
+
/* @__PURE__ */ jsx("code", { className: "rounded bg-background px-2 py-0.5 text-xs text-foreground", children: "npm run modules:prepare" }),
|
|
39
36
|
" ",
|
|
40
37
|
"whenever APIs change to refresh the generated registry."
|
|
41
38
|
] })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/api_docs/backend/docs/page.tsx"],
|
|
4
|
-
"sourcesContent": ["import { getApiDocsResources, resolveApiDocsBaseUrl } from '@open-mercato/core/modules/api_docs/lib/resources'\n\nexport default async function ApiDocsPage() {\n const baseUrl = resolveApiDocsBaseUrl()\n const resources = getApiDocsResources()\n\n return (\n <div className=\"space-y-8\">\n <div className=\"space-y-2\">\n <h1 className=\"text-2xl font-semibold\">API resources</h1>\n <p className=\"text-sm text-muted-foreground max-w-3xl\">\n Use the links below to explore the Open Mercato platform APIs. The OpenAPI exports are generated from the current module registry.\n </p>\n </div>\n <div className=\"grid gap-4 md:grid-cols-2\">\n {resources.map((resource) => (\n <div key={resource.href} className=\"rounded border bg-card p-4 h-full flex flex-col justify-between\">\n <div className=\"space-y-1.5\">\n <div className=\"text-base font-semibold\">{resource.label}</div>\n <p className=\"text-sm text-muted-foreground\">{resource.description}</p>\n </div>\n <div className=\"pt-4\">\n <a\n href={resource.href}\n target={resource.external ? '_blank' : undefined}\n rel={resource.external ? 'noreferrer' : undefined}\n className=\"inline-flex items-center text-sm font-medium text-primary hover:underline\"\n >\n {resource.actionLabel ?? (resource.external ? 'Open docs' : 'Open link')}\n </a>\n </div>\n </div>\n ))}\n </div>\n <div className=\"rounded border bg-muted/30 p-4 text-sm text-muted-foreground space-y-2\">\n <p>\n Current environment base URL:{' '}\n <code className=\"rounded bg-background px-2 py-0.5 text-xs text-foreground\">{baseUrl}</code>\n </p>\n <p>\n Run <code className=\"rounded bg-background px-2 py-0.5 text-xs text-foreground\">
|
|
5
|
-
"mappings": "AAQM,SACE,KADF;AARN,SAAS,qBAAqB,6BAA6B;AAE3D,eAAO,cAAqC;AAC1C,QAAM,UAAU,sBAAsB;AACtC,QAAM,YAAY,oBAAoB;AAEtC,SACE,qBAAC,SAAI,WAAU,aACb;AAAA,yBAAC,SAAI,WAAU,aACb;AAAA,0BAAC,QAAG,WAAU,0BAAyB,2BAAa;AAAA,MACpD,oBAAC,OAAE,WAAU,2CAA0C,gJAEvD;AAAA,OACF;AAAA,IACA,oBAAC,SAAI,WAAU,6BACZ,oBAAU,IAAI,CAAC,aACd,qBAAC,SAAwB,WAAU,mEACjC;AAAA,2BAAC,SAAI,WAAU,eACb;AAAA,4BAAC,SAAI,WAAU,2BAA2B,mBAAS,OAAM;AAAA,QACzD,oBAAC,OAAE,WAAU,iCAAiC,mBAAS,aAAY;AAAA,SACrE;AAAA,MACA,oBAAC,SAAI,WAAU,QACb;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,SAAS;AAAA,UACf,QAAQ,SAAS,WAAW,WAAW;AAAA,UACvC,KAAK,SAAS,WAAW,eAAe;AAAA,UACxC,WAAU;AAAA,UAET,mBAAS,gBAAgB,SAAS,WAAW,cAAc;AAAA;AAAA,MAC9D,GACF;AAAA,SAdQ,SAAS,IAenB,CACD,GACH;AAAA,IACA,qBAAC,SAAI,WAAU,0EACb;AAAA,2BAAC,OAAE;AAAA;AAAA,QAC6B;AAAA,QAC9B,oBAAC,UAAK,WAAU,6DAA6D,mBAAQ;AAAA,SACvF;AAAA,MACA,qBAAC,OAAE;AAAA;AAAA,QACG,oBAAC,UAAK,WAAU,6DAA4D,
|
|
4
|
+
"sourcesContent": ["import { getApiDocsResources, resolveApiDocsBaseUrl } from '@open-mercato/core/modules/api_docs/lib/resources'\n\nexport default async function ApiDocsPage() {\n const baseUrl = resolveApiDocsBaseUrl()\n const resources = getApiDocsResources()\n\n return (\n <div className=\"space-y-8\">\n <div className=\"space-y-2\">\n <h1 className=\"text-2xl font-semibold\">API resources</h1>\n <p className=\"text-sm text-muted-foreground max-w-3xl\">\n Use the links below to explore the Open Mercato platform APIs. The OpenAPI exports are generated from the current module registry.\n </p>\n </div>\n <div className=\"grid gap-4 md:grid-cols-2\">\n {resources.map((resource) => (\n <div key={resource.href} className=\"rounded border bg-card p-4 h-full flex flex-col justify-between\">\n <div className=\"space-y-1.5\">\n <div className=\"text-base font-semibold\">{resource.label}</div>\n <p className=\"text-sm text-muted-foreground\">{resource.description}</p>\n </div>\n <div className=\"pt-4\">\n <a\n href={resource.href}\n target={resource.external ? '_blank' : undefined}\n rel={resource.external ? 'noreferrer' : undefined}\n className=\"inline-flex items-center text-sm font-medium text-primary hover:underline\"\n >\n {resource.actionLabel ?? (resource.external ? 'Open docs' : 'Open link')}\n </a>\n </div>\n </div>\n ))}\n </div>\n <div className=\"rounded border bg-muted/30 p-4 text-sm text-muted-foreground space-y-2\">\n <p>\n Current environment base URL:{' '}\n <code className=\"rounded bg-background px-2 py-0.5 text-xs text-foreground\">{baseUrl}</code>\n </p>\n <p>\n Run <code className=\"rounded bg-background px-2 py-0.5 text-xs text-foreground\">npm run modules:prepare</code>{' '}\n whenever APIs change to refresh the generated registry.\n </p>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAQM,SACE,KADF;AARN,SAAS,qBAAqB,6BAA6B;AAE3D,eAAO,cAAqC;AAC1C,QAAM,UAAU,sBAAsB;AACtC,QAAM,YAAY,oBAAoB;AAEtC,SACE,qBAAC,SAAI,WAAU,aACb;AAAA,yBAAC,SAAI,WAAU,aACb;AAAA,0BAAC,QAAG,WAAU,0BAAyB,2BAAa;AAAA,MACpD,oBAAC,OAAE,WAAU,2CAA0C,gJAEvD;AAAA,OACF;AAAA,IACA,oBAAC,SAAI,WAAU,6BACZ,oBAAU,IAAI,CAAC,aACd,qBAAC,SAAwB,WAAU,mEACjC;AAAA,2BAAC,SAAI,WAAU,eACb;AAAA,4BAAC,SAAI,WAAU,2BAA2B,mBAAS,OAAM;AAAA,QACzD,oBAAC,OAAE,WAAU,iCAAiC,mBAAS,aAAY;AAAA,SACrE;AAAA,MACA,oBAAC,SAAI,WAAU,QACb;AAAA,QAAC;AAAA;AAAA,UACC,MAAM,SAAS;AAAA,UACf,QAAQ,SAAS,WAAW,WAAW;AAAA,UACvC,KAAK,SAAS,WAAW,eAAe;AAAA,UACxC,WAAU;AAAA,UAET,mBAAS,gBAAgB,SAAS,WAAW,cAAc;AAAA;AAAA,MAC9D,GACF;AAAA,SAdQ,SAAS,IAenB,CACD,GACH;AAAA,IACA,qBAAC,SAAI,WAAU,0EACb;AAAA,2BAAC,OAAE;AAAA;AAAA,QAC6B;AAAA,QAC9B,oBAAC,UAAK,WAAU,6DAA6D,mBAAQ;AAAA,SACvF;AAAA,MACA,qBAAC,OAAE;AAAA;AAAA,QACG,oBAAC,UAAK,WAAU,6DAA4D,qCAAuB;AAAA,QAAQ;AAAA,QAAI;AAAA,SAErH;AAAA,OACF;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -291,8 +291,6 @@ async function ensureDefaultRoleAcls(em, tenantId, options = {}) {
|
|
|
291
291
|
"catalog.variants.manage",
|
|
292
292
|
"catalog.pricing.manage",
|
|
293
293
|
"sales.*",
|
|
294
|
-
"sales.widgets.new-orders",
|
|
295
|
-
"sales.widgets.new-quotes",
|
|
296
294
|
"audit_logs.*",
|
|
297
295
|
"directory.organizations.view",
|
|
298
296
|
"directory.organizations.manage",
|
|
@@ -333,8 +331,6 @@ async function ensureDefaultRoleAcls(em, tenantId, options = {}) {
|
|
|
333
331
|
"catalog.variants.manage",
|
|
334
332
|
"catalog.pricing.manage",
|
|
335
333
|
"sales.*",
|
|
336
|
-
"sales.widgets.new-orders",
|
|
337
|
-
"sales.widgets.new-quotes",
|
|
338
334
|
"dictionaries.view",
|
|
339
335
|
"example.*",
|
|
340
336
|
"example.widgets.*",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/auth/lib/setup-app.ts"],
|
|
4
|
-
"sourcesContent": ["import { hash } from 'bcryptjs'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { Role, RoleAcl, User, UserRole } from '@open-mercato/core/modules/auth/data/entities'\nimport { Tenant, Organization } from '@open-mercato/core/modules/directory/data/entities'\nimport { rebuildHierarchyForTenant } from '@open-mercato/core/modules/directory/lib/hierarchy'\nimport { normalizeTenantId } from './tenantAccess'\nimport { SalesSettings, SalesDocumentSequence } from '@open-mercato/core/modules/sales/data/entities'\nimport {\n DEFAULT_ORDER_NUMBER_FORMAT,\n DEFAULT_QUOTE_NUMBER_FORMAT,\n} from '@open-mercato/core/modules/sales/lib/documentNumberTokens'\nimport { computeEmailHash } from '@open-mercato/core/modules/auth/lib/emailHash'\nimport { isEncryptionDebugEnabled, isTenantDataEncryptionEnabled } from '@open-mercato/shared/lib/encryption/toggles'\nimport { EncryptionMap } from '@open-mercato/core/modules/entities/data/entities'\nimport { DEFAULT_ENCRYPTION_MAPS } from '@open-mercato/core/modules/entities/lib/encryptionDefaults'\nimport { createKmsService } from '@open-mercato/shared/lib/encryption/kms'\nimport { TenantDataEncryptionService } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\n\nconst DEFAULT_ROLE_NAMES = ['employee', 'admin', 'superadmin'] as const\nconst DEMO_SUPERADMIN_EMAIL = 'superadmin@acme.com'\n\nexport type EnsureRolesOptions = {\n roleNames?: string[]\n tenantId?: string | null\n}\n\nasync function ensureRolesInContext(\n em: EntityManager,\n roleNames: string[],\n tenantId: string | null,\n) {\n for (const name of roleNames) {\n const existing = await em.findOne(Role, { name, tenantId })\n if (existing) continue\n if (tenantId !== null) {\n const globalRole = await em.findOne(Role, { name, tenantId: null })\n if (globalRole) {\n globalRole.tenantId = tenantId\n em.persist(globalRole)\n continue\n }\n }\n em.persist(em.create(Role, { name, tenantId, createdAt: new Date() }))\n }\n}\n\nexport async function ensureRoles(em: EntityManager, options: EnsureRolesOptions = {}) {\n const roleNames = options.roleNames ?? [...DEFAULT_ROLE_NAMES]\n const tenantId = normalizeTenantId(options.tenantId ?? null) ?? null\n await em.transactional(async (tem) => {\n await ensureRolesInContext(tem, roleNames, tenantId)\n await tem.flush()\n })\n}\n\nasync function findRoleByName(\n em: EntityManager,\n name: string,\n tenantId: string | null,\n): Promise<Role | null> {\n const normalizedTenant = normalizeTenantId(tenantId ?? null) ?? null\n let role = await em.findOne(Role, { name, tenantId: normalizedTenant })\n if (!role && normalizedTenant !== null) {\n role = await em.findOne(Role, { name, tenantId: null })\n }\n return role\n}\n\nasync function findRoleByNameOrFail(\n em: EntityManager,\n name: string,\n tenantId: string | null,\n): Promise<Role> {\n const role = await findRoleByName(em, name, tenantId)\n if (!role) throw new Error(`ROLE_NOT_FOUND:${name}`)\n return role\n}\n\ntype PrimaryUserInput = {\n email: string\n password?: string\n hashedPassword?: string | null\n firstName?: string | null\n lastName?: string | null\n displayName?: string | null\n confirm?: boolean\n}\n\nexport type SetupInitialTenantOptions = {\n orgName: string\n primaryUser: PrimaryUserInput\n roleNames?: string[]\n includeDerivedUsers?: boolean\n failIfUserExists?: boolean\n primaryUserRoles?: string[]\n includeSuperadminRole?: boolean\n}\n\nexport type SetupInitialTenantResult = {\n tenantId: string\n organizationId: string\n users: Array<{ user: User; roles: string[]; created: boolean }>\n reusedExistingUser: boolean\n}\n\nexport async function setupInitialTenant(\n em: EntityManager,\n options: SetupInitialTenantOptions,\n): Promise<SetupInitialTenantResult> {\n const {\n primaryUser,\n includeDerivedUsers = true,\n failIfUserExists = false,\n primaryUserRoles,\n includeSuperadminRole = true,\n } = options\n const primaryRolesInput = primaryUserRoles && primaryUserRoles.length ? primaryUserRoles : ['superadmin']\n const primaryRoles = includeSuperadminRole\n ? primaryRolesInput\n : primaryRolesInput.filter((role) => role !== 'superadmin')\n if (primaryRoles.length === 0) {\n throw new Error('PRIMARY_ROLES_REQUIRED')\n }\n const defaultRoleNames = options.roleNames ?? [...DEFAULT_ROLE_NAMES]\n const resolvedRoleNames = includeSuperadminRole\n ? defaultRoleNames\n : defaultRoleNames.filter((role) => role !== 'superadmin')\n const roleNames = Array.from(new Set([...resolvedRoleNames, ...primaryRoles]))\n\n const mainEmail = primaryUser.email\n const existingUser = await em.findOne(User, { email: mainEmail })\n if (existingUser && failIfUserExists) {\n throw new Error('USER_EXISTS')\n }\n\n let tenantId: string | undefined\n let organizationId: string | undefined\n let reusedExistingUser = false\n const userSnapshots: Array<{ user: User; roles: string[]; created: boolean }> = []\n\n await em.transactional(async (tem) => {\n if (!existingUser) return\n reusedExistingUser = true\n tenantId = existingUser.tenantId ? String(existingUser.tenantId) : undefined\n organizationId = existingUser.organizationId ? String(existingUser.organizationId) : undefined\n const roleTenantId = normalizeTenantId(existingUser.tenantId ?? null) ?? null\n\n await ensureRolesInContext(tem, roleNames, roleTenantId)\n await tem.flush()\n\n const requiredRoleSet = new Set([...roleNames, ...primaryRoles])\n const links = await findWithDecryption(\n tem,\n UserRole,\n { user: existingUser },\n { populate: ['role'] },\n { tenantId: roleTenantId, organizationId: null },\n )\n const currentRoles = new Set(links.map((link) => link.role.name))\n for (const roleName of requiredRoleSet) {\n if (!currentRoles.has(roleName)) {\n const role = await findRoleByNameOrFail(tem, roleName, roleTenantId)\n tem.persist(tem.create(UserRole, { user: existingUser, role, createdAt: new Date() }))\n }\n }\n await tem.flush()\n const roles = Array.from(new Set([...currentRoles, ...roleNames]))\n userSnapshots.push({ user: existingUser, roles, created: false })\n })\n\n if (!existingUser) {\n const baseUsers: Array<{ email: string; roles: string[]; name?: string | null }> = [\n { email: primaryUser.email, roles: primaryRoles, name: resolvePrimaryName(primaryUser) },\n ]\n if (includeDerivedUsers) {\n const [local, domain] = String(primaryUser.email).split('@')\n const isSuperadminLocal = (local || '').toLowerCase() === 'superadmin' && !!domain\n if (isSuperadminLocal) {\n baseUsers.push({ email: `admin@${domain}`, roles: ['admin'] })\n baseUsers.push({ email: `employee@${domain}`, roles: ['employee'] })\n }\n }\n const passwordHash = await resolvePasswordHash(primaryUser)\n\n await em.transactional(async (tem) => {\n const tenant = tem.create(Tenant, {\n name: `${options.orgName} Tenant`,\n isActive: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n tem.persist(tenant)\n await tem.flush()\n\n const organization = tem.create(Organization, {\n name: options.orgName,\n tenant,\n isActive: true,\n depth: 0,\n ancestorIds: [],\n childIds: [],\n descendantIds: [],\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n tem.persist(organization)\n await tem.flush()\n\n tenantId = String(tenant.id)\n organizationId = String(organization.id)\n const roleTenantId = tenantId\n\n if (isTenantDataEncryptionEnabled()) {\n try {\n const kms = createKmsService()\n if (kms.isHealthy()) {\n if (isEncryptionDebugEnabled()) {\n console.info('\uD83D\uDD11 [encryption][setup] provisioning tenant DEK', { tenantId: String(tenant.id) })\n }\n await kms.createTenantDek(String(tenant.id))\n if (isEncryptionDebugEnabled()) {\n console.info('\uD83D\uDD11 [encryption][setup] created tenant DEK during setup', { tenantId: String(tenant.id) })\n }\n } else {\n if (isEncryptionDebugEnabled()) {\n console.warn('\u26A0\uFE0F [encryption][setup] KMS not healthy, skipping tenant DEK creation', { tenantId: String(tenant.id) })\n }\n }\n } catch (err) {\n if (isEncryptionDebugEnabled()) {\n console.warn('\u26A0\uFE0F [encryption][setup] Failed to create tenant DEK', err)\n }\n }\n }\n\n await ensureRolesInContext(tem, roleNames, roleTenantId)\n await tem.flush()\n\n if (isTenantDataEncryptionEnabled()) {\n for (const spec of DEFAULT_ENCRYPTION_MAPS) {\n const existing = await tem.findOne(EncryptionMap, { entityId: spec.entityId, tenantId: tenant.id, organizationId: organization.id, deletedAt: null })\n if (!existing) {\n tem.persist(tem.create(EncryptionMap, {\n entityId: spec.entityId,\n tenantId: tenant.id,\n organizationId: organization.id,\n fieldsJson: spec.fields,\n isActive: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n }))\n } else {\n existing.fieldsJson = spec.fields\n existing.isActive = true\n }\n }\n await tem.flush()\n }\n })\n\n await em.transactional(async (tem) => {\n if (!tenantId || !organizationId) return\n const roleTenantId = tenantId\n const encryptionService = isTenantDataEncryptionEnabled()\n ? new TenantDataEncryptionService(tem as any, { kms: createKmsService() })\n : null\n if (encryptionService) {\n await encryptionService.invalidateMap('auth:user', String(tenantId), String(organizationId))\n await encryptionService.invalidateMap('auth:user', String(tenantId), null)\n }\n\n for (const base of baseUsers) {\n let user = await tem.findOne(User, { email: base.email })\n const confirm = primaryUser.confirm ?? true\n const encryptedPayload = encryptionService\n ? await encryptionService.encryptEntityPayload('auth:user', { email: base.email }, tenantId, organizationId)\n : { email: base.email, emailHash: computeEmailHash(base.email) }\n if (user) {\n user.passwordHash = passwordHash\n user.organizationId = organizationId\n user.tenantId = tenantId\n if (isTenantDataEncryptionEnabled()) {\n user.email = encryptedPayload.email as any\n user.emailHash = (encryptedPayload as any).emailHash ?? computeEmailHash(base.email)\n }\n if (base.name) user.name = base.name\n if (confirm) user.isConfirmed = true\n tem.persist(user)\n userSnapshots.push({ user, roles: base.roles, created: false })\n } else {\n user = tem.create(User, {\n email: (encryptedPayload as any).email ?? base.email,\n emailHash: isTenantDataEncryptionEnabled() ? (encryptedPayload as any).emailHash ?? computeEmailHash(base.email) : undefined,\n passwordHash,\n organizationId,\n tenantId,\n name: base.name ?? undefined,\n isConfirmed: confirm,\n createdAt: new Date(),\n })\n tem.persist(user)\n userSnapshots.push({ user, roles: base.roles, created: true })\n }\n await tem.flush()\n for (const roleName of base.roles) {\n const role = await findRoleByNameOrFail(tem, roleName, roleTenantId)\n const existingLink = await tem.findOne(UserRole, { user, role })\n if (!existingLink) tem.persist(tem.create(UserRole, { user, role, createdAt: new Date() }))\n }\n await tem.flush()\n }\n })\n }\n\n if (!tenantId || !organizationId) {\n throw new Error('SETUP_FAILED')\n }\n\n if (!reusedExistingUser) {\n await rebuildHierarchyForTenant(em, tenantId)\n }\n\n await ensureDefaultRoleAcls(em, tenantId, { includeSuperadminRole })\n await deactivateDemoSuperAdminIfSelfOnboardingEnabled(em)\n await ensureSalesNumberingDefaults(em, { tenantId, organizationId })\n\n return {\n tenantId,\n organizationId,\n users: userSnapshots,\n reusedExistingUser,\n }\n}\n\nfunction resolvePrimaryName(input: PrimaryUserInput): string | null {\n if (input.displayName && input.displayName.trim()) return input.displayName.trim()\n const parts = [input.firstName, input.lastName].map((value) => value?.trim()).filter(Boolean)\n if (parts.length) return parts.join(' ')\n return null\n}\n\nasync function resolvePasswordHash(input: PrimaryUserInput): Promise<string | null> {\n if (typeof input.hashedPassword === 'string') return input.hashedPassword\n if (input.password) return hash(input.password, 10)\n return null\n}\n\nasync function ensureDefaultRoleAcls(\n em: EntityManager,\n tenantId: string,\n options: { includeSuperadminRole?: boolean } = {},\n) {\n const includeSuperadminRole = options.includeSuperadminRole ?? true\n const roleTenantId = normalizeTenantId(tenantId) ?? null\n const superadminRole = includeSuperadminRole ? await findRoleByName(em, 'superadmin', roleTenantId) : null\n const adminRole = await findRoleByName(em, 'admin', roleTenantId)\n const employeeRole = await findRoleByName(em, 'employee', roleTenantId)\n\n if (includeSuperadminRole && superadminRole) {\n await ensureRoleAclFor(em, superadminRole, tenantId, ['directory.tenants.*'], { isSuperAdmin: true })\n }\n if (adminRole) {\n const adminFeatures = [\n 'auth.*',\n 'entities.*',\n 'attachments.*',\n 'attachments.view',\n 'attachments.manage',\n 'query_index.*',\n 'search.*',\n 'vector.*',\n 'feature_toggles.*',\n 'configs.system_status.view',\n 'configs.cache.view',\n 'configs.cache.manage',\n 'configs.manage',\n 'catalog.*',\n 'catalog.variants.manage',\n 'catalog.pricing.manage',\n 'sales.*',\n 'sales.widgets.new-orders',\n 'sales.widgets.new-quotes',\n 'audit_logs.*',\n 'directory.organizations.view',\n 'directory.organizations.manage',\n 'customers.*',\n 'customers.people.view',\n 'customers.people.manage',\n 'customers.companies.view',\n 'customers.companies.manage',\n 'customers.deals.view',\n 'customers.deals.manage',\n 'dictionaries.view',\n 'dictionaries.manage',\n 'example.*',\n 'dashboards.*',\n 'dashboards.admin.assign-widgets',\n 'api_keys.*',\n 'perspectives.use',\n 'perspectives.role_defaults',\n 'business_rules.*',\n 'workflows.*',\n 'currencies.*',\n 'staff.*',\n 'staff.leave_requests.manage',\n 'resources.*',\n 'planner.*',\n ]\n await ensureRoleAclFor(em, adminRole, tenantId, adminFeatures, { remove: ['directory.organizations.*', 'directory.tenants.*'] })\n }\n if (employeeRole) {\n await ensureRoleAclFor(em, employeeRole, tenantId, [\n 'customers.*',\n 'customers.people.view',\n 'customers.people.manage',\n 'customers.companies.view',\n 'customers.companies.manage',\n 'vector.*',\n 'catalog.*',\n 'catalog.variants.manage',\n 'catalog.pricing.manage',\n 'sales.*',\n 'sales.widgets.new-orders',\n 'sales.widgets.new-quotes',\n 'dictionaries.view',\n 'example.*',\n 'example.widgets.*',\n 'dashboards.view',\n 'dashboards.configure',\n 'audit_logs.undo_self',\n 'perspectives.use',\n 'staff.leave_requests.send',\n 'staff.my_availability.view',\n 'staff.my_availability.manage',\n 'staff.my_leave_requests.view',\n 'staff.my_leave_requests.send',\n 'planner.view',\n ])\n }\n}\n\nasync function ensureRoleAclFor(\n em: EntityManager,\n role: Role,\n tenantId: string,\n features: string[],\n options: { isSuperAdmin?: boolean; remove?: string[] } = {},\n) {\n const existing = await em.findOne(RoleAcl, { role, tenantId })\n if (!existing) {\n const acl = em.create(RoleAcl, {\n role,\n tenantId,\n featuresJson: features,\n isSuperAdmin: !!options.isSuperAdmin,\n createdAt: new Date(),\n })\n await em.persistAndFlush(acl)\n return\n }\n const currentFeatures = Array.isArray(existing.featuresJson) ? existing.featuresJson : []\n const merged = Array.from(new Set([...currentFeatures, ...features]))\n const removeSet = new Set(options.remove ?? [])\n const sanitized =\n removeSet.size\n ? merged.filter((value) => {\n if (removeSet.has(value)) return false\n for (const entry of removeSet) {\n if (entry.endsWith('.*')) {\n const prefix = entry.slice(0, -1) // keep trailing dot\n if (value === entry || value.startsWith(prefix)) return false\n }\n }\n return true\n })\n : merged\n const changed =\n sanitized.length !== currentFeatures.length ||\n sanitized.some((value, index) => value !== currentFeatures[index])\n if (changed) existing.featuresJson = sanitized\n if (options.isSuperAdmin && !existing.isSuperAdmin) {\n existing.isSuperAdmin = true\n }\n if (changed || options.isSuperAdmin) {\n await em.persistAndFlush(existing)\n }\n}\n\nasync function deactivateDemoSuperAdminIfSelfOnboardingEnabled(em: EntityManager) {\n if (process.env.SELF_SERVICE_ONBOARDING_ENABLED !== 'true') return\n try {\n const user = await em.findOne(User, { email: DEMO_SUPERADMIN_EMAIL })\n if (!user) return\n let dirty = false\n if (user.passwordHash) {\n user.passwordHash = null\n dirty = true\n }\n if (user.isConfirmed !== false) {\n user.isConfirmed = false\n dirty = true\n }\n if (dirty) {\n await em.persistAndFlush(user)\n }\n } catch (error) {\n console.error('[auth.setup] failed to deactivate demo superadmin user', error)\n }\n}\n\nasync function ensureSalesNumberingDefaults(\n em: EntityManager,\n scope: { tenantId: string; organizationId: string },\n) {\n const repo = (em as any).getRepository?.(SalesSettings)\n const findSettings = async () =>\n repo?.findOne({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n }) ??\n (em as any).findOne?.(SalesSettings, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n\n const exists = await findSettings()\n if (!exists) {\n const settings =\n repo?.create?.({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n orderNumberFormat: DEFAULT_ORDER_NUMBER_FORMAT,\n quoteNumberFormat: DEFAULT_QUOTE_NUMBER_FORMAT,\n createdAt: new Date(),\n updatedAt: new Date(),\n }) ??\n (em as any).create?.(SalesSettings, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n orderNumberFormat: DEFAULT_ORDER_NUMBER_FORMAT,\n quoteNumberFormat: DEFAULT_QUOTE_NUMBER_FORMAT,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n if (settings && (em as any).persist) {\n em.persist(settings)\n }\n }\n\n const sequenceRepo = (em as any).getRepository?.(SalesDocumentSequence)\n const kinds: Array<'order' | 'quote'> = ['order', 'quote']\n for (const kind of kinds) {\n const seq =\n sequenceRepo?.findOne({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n }) ??\n (em as any).findOne?.(SalesDocumentSequence, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n })\n if (!seq) {\n const entry =\n sequenceRepo?.create?.({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n currentValue: 0,\n createdAt: new Date(),\n updatedAt: new Date(),\n }) ??\n (em as any).create?.(SalesDocumentSequence, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n currentValue: 0,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n if (entry && (em as any).persist) {\n em.persist(entry)\n }\n }\n }\n\n if ((em as any).flush) {\n await em.flush()\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,MAAM,SAAS,MAAM,gBAAgB;AAC9C,SAAS,QAAQ,oBAAoB;AACrC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,SAAS,eAAe,6BAA6B;AACrD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,0BAA0B,qCAAqC;AACxE,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AACjC,SAAS,mCAAmC;AAC5C,SAAS,0BAA0B;AAEnC,MAAM,qBAAqB,CAAC,YAAY,SAAS,YAAY;AAC7D,MAAM,wBAAwB;AAO9B,eAAe,qBACb,IACA,WACA,UACA;AACA,aAAW,QAAQ,WAAW;AAC5B,UAAM,WAAW,MAAM,GAAG,QAAQ,MA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,SAAS,uBAAuB;AAAA,QAC1C,UAAU,MAAM;AAAA,QAChB,gBAAgB,MAAM;AAAA,QACtB,cAAc;AAAA,QACd,cAAc;AAAA,QACd,WAAW,oBAAI,KAAK;AAAA,QACpB,WAAW,oBAAI,KAAK;AAAA,MACtB,CAAC;AACH,UAAI,SAAU,GAAW,SAAS;AAChC,WAAG,QAAQ,KAAK;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAEA,MAAK,GAAW,OAAO;AACrB,UAAM,GAAG,MAAM;AAAA,EACjB;AACF;",
|
|
4
|
+
"sourcesContent": ["import { hash } from 'bcryptjs'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { Role, RoleAcl, User, UserRole } from '@open-mercato/core/modules/auth/data/entities'\nimport { Tenant, Organization } from '@open-mercato/core/modules/directory/data/entities'\nimport { rebuildHierarchyForTenant } from '@open-mercato/core/modules/directory/lib/hierarchy'\nimport { normalizeTenantId } from './tenantAccess'\nimport { SalesSettings, SalesDocumentSequence } from '@open-mercato/core/modules/sales/data/entities'\nimport {\n DEFAULT_ORDER_NUMBER_FORMAT,\n DEFAULT_QUOTE_NUMBER_FORMAT,\n} from '@open-mercato/core/modules/sales/lib/documentNumberTokens'\nimport { computeEmailHash } from '@open-mercato/core/modules/auth/lib/emailHash'\nimport { isEncryptionDebugEnabled, isTenantDataEncryptionEnabled } from '@open-mercato/shared/lib/encryption/toggles'\nimport { EncryptionMap } from '@open-mercato/core/modules/entities/data/entities'\nimport { DEFAULT_ENCRYPTION_MAPS } from '@open-mercato/core/modules/entities/lib/encryptionDefaults'\nimport { createKmsService } from '@open-mercato/shared/lib/encryption/kms'\nimport { TenantDataEncryptionService } from '@open-mercato/shared/lib/encryption/tenantDataEncryptionService'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\n\nconst DEFAULT_ROLE_NAMES = ['employee', 'admin', 'superadmin'] as const\nconst DEMO_SUPERADMIN_EMAIL = 'superadmin@acme.com'\n\nexport type EnsureRolesOptions = {\n roleNames?: string[]\n tenantId?: string | null\n}\n\nasync function ensureRolesInContext(\n em: EntityManager,\n roleNames: string[],\n tenantId: string | null,\n) {\n for (const name of roleNames) {\n const existing = await em.findOne(Role, { name, tenantId })\n if (existing) continue\n if (tenantId !== null) {\n const globalRole = await em.findOne(Role, { name, tenantId: null })\n if (globalRole) {\n globalRole.tenantId = tenantId\n em.persist(globalRole)\n continue\n }\n }\n em.persist(em.create(Role, { name, tenantId, createdAt: new Date() }))\n }\n}\n\nexport async function ensureRoles(em: EntityManager, options: EnsureRolesOptions = {}) {\n const roleNames = options.roleNames ?? [...DEFAULT_ROLE_NAMES]\n const tenantId = normalizeTenantId(options.tenantId ?? null) ?? null\n await em.transactional(async (tem) => {\n await ensureRolesInContext(tem, roleNames, tenantId)\n await tem.flush()\n })\n}\n\nasync function findRoleByName(\n em: EntityManager,\n name: string,\n tenantId: string | null,\n): Promise<Role | null> {\n const normalizedTenant = normalizeTenantId(tenantId ?? null) ?? null\n let role = await em.findOne(Role, { name, tenantId: normalizedTenant })\n if (!role && normalizedTenant !== null) {\n role = await em.findOne(Role, { name, tenantId: null })\n }\n return role\n}\n\nasync function findRoleByNameOrFail(\n em: EntityManager,\n name: string,\n tenantId: string | null,\n): Promise<Role> {\n const role = await findRoleByName(em, name, tenantId)\n if (!role) throw new Error(`ROLE_NOT_FOUND:${name}`)\n return role\n}\n\ntype PrimaryUserInput = {\n email: string\n password?: string\n hashedPassword?: string | null\n firstName?: string | null\n lastName?: string | null\n displayName?: string | null\n confirm?: boolean\n}\n\nexport type SetupInitialTenantOptions = {\n orgName: string\n primaryUser: PrimaryUserInput\n roleNames?: string[]\n includeDerivedUsers?: boolean\n failIfUserExists?: boolean\n primaryUserRoles?: string[]\n includeSuperadminRole?: boolean\n}\n\nexport type SetupInitialTenantResult = {\n tenantId: string\n organizationId: string\n users: Array<{ user: User; roles: string[]; created: boolean }>\n reusedExistingUser: boolean\n}\n\nexport async function setupInitialTenant(\n em: EntityManager,\n options: SetupInitialTenantOptions,\n): Promise<SetupInitialTenantResult> {\n const {\n primaryUser,\n includeDerivedUsers = true,\n failIfUserExists = false,\n primaryUserRoles,\n includeSuperadminRole = true,\n } = options\n const primaryRolesInput = primaryUserRoles && primaryUserRoles.length ? primaryUserRoles : ['superadmin']\n const primaryRoles = includeSuperadminRole\n ? primaryRolesInput\n : primaryRolesInput.filter((role) => role !== 'superadmin')\n if (primaryRoles.length === 0) {\n throw new Error('PRIMARY_ROLES_REQUIRED')\n }\n const defaultRoleNames = options.roleNames ?? [...DEFAULT_ROLE_NAMES]\n const resolvedRoleNames = includeSuperadminRole\n ? defaultRoleNames\n : defaultRoleNames.filter((role) => role !== 'superadmin')\n const roleNames = Array.from(new Set([...resolvedRoleNames, ...primaryRoles]))\n\n const mainEmail = primaryUser.email\n const existingUser = await em.findOne(User, { email: mainEmail })\n if (existingUser && failIfUserExists) {\n throw new Error('USER_EXISTS')\n }\n\n let tenantId: string | undefined\n let organizationId: string | undefined\n let reusedExistingUser = false\n const userSnapshots: Array<{ user: User; roles: string[]; created: boolean }> = []\n\n await em.transactional(async (tem) => {\n if (!existingUser) return\n reusedExistingUser = true\n tenantId = existingUser.tenantId ? String(existingUser.tenantId) : undefined\n organizationId = existingUser.organizationId ? String(existingUser.organizationId) : undefined\n const roleTenantId = normalizeTenantId(existingUser.tenantId ?? null) ?? null\n\n await ensureRolesInContext(tem, roleNames, roleTenantId)\n await tem.flush()\n\n const requiredRoleSet = new Set([...roleNames, ...primaryRoles])\n const links = await findWithDecryption(\n tem,\n UserRole,\n { user: existingUser },\n { populate: ['role'] },\n { tenantId: roleTenantId, organizationId: null },\n )\n const currentRoles = new Set(links.map((link) => link.role.name))\n for (const roleName of requiredRoleSet) {\n if (!currentRoles.has(roleName)) {\n const role = await findRoleByNameOrFail(tem, roleName, roleTenantId)\n tem.persist(tem.create(UserRole, { user: existingUser, role, createdAt: new Date() }))\n }\n }\n await tem.flush()\n const roles = Array.from(new Set([...currentRoles, ...roleNames]))\n userSnapshots.push({ user: existingUser, roles, created: false })\n })\n\n if (!existingUser) {\n const baseUsers: Array<{ email: string; roles: string[]; name?: string | null }> = [\n { email: primaryUser.email, roles: primaryRoles, name: resolvePrimaryName(primaryUser) },\n ]\n if (includeDerivedUsers) {\n const [local, domain] = String(primaryUser.email).split('@')\n const isSuperadminLocal = (local || '').toLowerCase() === 'superadmin' && !!domain\n if (isSuperadminLocal) {\n baseUsers.push({ email: `admin@${domain}`, roles: ['admin'] })\n baseUsers.push({ email: `employee@${domain}`, roles: ['employee'] })\n }\n }\n const passwordHash = await resolvePasswordHash(primaryUser)\n\n await em.transactional(async (tem) => {\n const tenant = tem.create(Tenant, {\n name: `${options.orgName} Tenant`,\n isActive: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n tem.persist(tenant)\n await tem.flush()\n\n const organization = tem.create(Organization, {\n name: options.orgName,\n tenant,\n isActive: true,\n depth: 0,\n ancestorIds: [],\n childIds: [],\n descendantIds: [],\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n tem.persist(organization)\n await tem.flush()\n\n tenantId = String(tenant.id)\n organizationId = String(organization.id)\n const roleTenantId = tenantId\n\n if (isTenantDataEncryptionEnabled()) {\n try {\n const kms = createKmsService()\n if (kms.isHealthy()) {\n if (isEncryptionDebugEnabled()) {\n console.info('\uD83D\uDD11 [encryption][setup] provisioning tenant DEK', { tenantId: String(tenant.id) })\n }\n await kms.createTenantDek(String(tenant.id))\n if (isEncryptionDebugEnabled()) {\n console.info('\uD83D\uDD11 [encryption][setup] created tenant DEK during setup', { tenantId: String(tenant.id) })\n }\n } else {\n if (isEncryptionDebugEnabled()) {\n console.warn('\u26A0\uFE0F [encryption][setup] KMS not healthy, skipping tenant DEK creation', { tenantId: String(tenant.id) })\n }\n }\n } catch (err) {\n if (isEncryptionDebugEnabled()) {\n console.warn('\u26A0\uFE0F [encryption][setup] Failed to create tenant DEK', err)\n }\n }\n }\n\n await ensureRolesInContext(tem, roleNames, roleTenantId)\n await tem.flush()\n\n if (isTenantDataEncryptionEnabled()) {\n for (const spec of DEFAULT_ENCRYPTION_MAPS) {\n const existing = await tem.findOne(EncryptionMap, { entityId: spec.entityId, tenantId: tenant.id, organizationId: organization.id, deletedAt: null })\n if (!existing) {\n tem.persist(tem.create(EncryptionMap, {\n entityId: spec.entityId,\n tenantId: tenant.id,\n organizationId: organization.id,\n fieldsJson: spec.fields,\n isActive: true,\n createdAt: new Date(),\n updatedAt: new Date(),\n }))\n } else {\n existing.fieldsJson = spec.fields\n existing.isActive = true\n }\n }\n await tem.flush()\n }\n })\n\n await em.transactional(async (tem) => {\n if (!tenantId || !organizationId) return\n const roleTenantId = tenantId\n const encryptionService = isTenantDataEncryptionEnabled()\n ? new TenantDataEncryptionService(tem as any, { kms: createKmsService() })\n : null\n if (encryptionService) {\n await encryptionService.invalidateMap('auth:user', String(tenantId), String(organizationId))\n await encryptionService.invalidateMap('auth:user', String(tenantId), null)\n }\n\n for (const base of baseUsers) {\n let user = await tem.findOne(User, { email: base.email })\n const confirm = primaryUser.confirm ?? true\n const encryptedPayload = encryptionService\n ? await encryptionService.encryptEntityPayload('auth:user', { email: base.email }, tenantId, organizationId)\n : { email: base.email, emailHash: computeEmailHash(base.email) }\n if (user) {\n user.passwordHash = passwordHash\n user.organizationId = organizationId\n user.tenantId = tenantId\n if (isTenantDataEncryptionEnabled()) {\n user.email = encryptedPayload.email as any\n user.emailHash = (encryptedPayload as any).emailHash ?? computeEmailHash(base.email)\n }\n if (base.name) user.name = base.name\n if (confirm) user.isConfirmed = true\n tem.persist(user)\n userSnapshots.push({ user, roles: base.roles, created: false })\n } else {\n user = tem.create(User, {\n email: (encryptedPayload as any).email ?? base.email,\n emailHash: isTenantDataEncryptionEnabled() ? (encryptedPayload as any).emailHash ?? computeEmailHash(base.email) : undefined,\n passwordHash,\n organizationId,\n tenantId,\n name: base.name ?? undefined,\n isConfirmed: confirm,\n createdAt: new Date(),\n })\n tem.persist(user)\n userSnapshots.push({ user, roles: base.roles, created: true })\n }\n await tem.flush()\n for (const roleName of base.roles) {\n const role = await findRoleByNameOrFail(tem, roleName, roleTenantId)\n const existingLink = await tem.findOne(UserRole, { user, role })\n if (!existingLink) tem.persist(tem.create(UserRole, { user, role, createdAt: new Date() }))\n }\n await tem.flush()\n }\n })\n }\n\n if (!tenantId || !organizationId) {\n throw new Error('SETUP_FAILED')\n }\n\n if (!reusedExistingUser) {\n await rebuildHierarchyForTenant(em, tenantId)\n }\n\n await ensureDefaultRoleAcls(em, tenantId, { includeSuperadminRole })\n await deactivateDemoSuperAdminIfSelfOnboardingEnabled(em)\n await ensureSalesNumberingDefaults(em, { tenantId, organizationId })\n\n return {\n tenantId,\n organizationId,\n users: userSnapshots,\n reusedExistingUser,\n }\n}\n\nfunction resolvePrimaryName(input: PrimaryUserInput): string | null {\n if (input.displayName && input.displayName.trim()) return input.displayName.trim()\n const parts = [input.firstName, input.lastName].map((value) => value?.trim()).filter(Boolean)\n if (parts.length) return parts.join(' ')\n return null\n}\n\nasync function resolvePasswordHash(input: PrimaryUserInput): Promise<string | null> {\n if (typeof input.hashedPassword === 'string') return input.hashedPassword\n if (input.password) return hash(input.password, 10)\n return null\n}\n\nasync function ensureDefaultRoleAcls(\n em: EntityManager,\n tenantId: string,\n options: { includeSuperadminRole?: boolean } = {},\n) {\n const includeSuperadminRole = options.includeSuperadminRole ?? true\n const roleTenantId = normalizeTenantId(tenantId) ?? null\n const superadminRole = includeSuperadminRole ? await findRoleByName(em, 'superadmin', roleTenantId) : null\n const adminRole = await findRoleByName(em, 'admin', roleTenantId)\n const employeeRole = await findRoleByName(em, 'employee', roleTenantId)\n\n if (includeSuperadminRole && superadminRole) {\n await ensureRoleAclFor(em, superadminRole, tenantId, ['directory.tenants.*'], { isSuperAdmin: true })\n }\n if (adminRole) {\n const adminFeatures = [\n 'auth.*',\n 'entities.*',\n 'attachments.*',\n 'attachments.view',\n 'attachments.manage',\n 'query_index.*',\n 'search.*',\n 'vector.*',\n 'feature_toggles.*',\n 'configs.system_status.view',\n 'configs.cache.view',\n 'configs.cache.manage',\n 'configs.manage',\n 'catalog.*',\n 'catalog.variants.manage',\n 'catalog.pricing.manage',\n 'sales.*',\n 'audit_logs.*',\n 'directory.organizations.view',\n 'directory.organizations.manage',\n 'customers.*',\n 'customers.people.view',\n 'customers.people.manage',\n 'customers.companies.view',\n 'customers.companies.manage',\n 'customers.deals.view',\n 'customers.deals.manage',\n 'dictionaries.view',\n 'dictionaries.manage',\n 'example.*',\n 'dashboards.*',\n 'dashboards.admin.assign-widgets',\n 'api_keys.*',\n 'perspectives.use',\n 'perspectives.role_defaults',\n 'business_rules.*',\n 'workflows.*',\n 'currencies.*',\n 'staff.*',\n 'staff.leave_requests.manage',\n 'resources.*',\n 'planner.*',\n ]\n await ensureRoleAclFor(em, adminRole, tenantId, adminFeatures, { remove: ['directory.organizations.*', 'directory.tenants.*'] })\n }\n if (employeeRole) {\n await ensureRoleAclFor(em, employeeRole, tenantId, [\n 'customers.*',\n 'customers.people.view',\n 'customers.people.manage',\n 'customers.companies.view',\n 'customers.companies.manage',\n 'vector.*',\n 'catalog.*',\n 'catalog.variants.manage',\n 'catalog.pricing.manage',\n 'sales.*',\n 'dictionaries.view',\n 'example.*',\n 'example.widgets.*',\n 'dashboards.view',\n 'dashboards.configure',\n 'audit_logs.undo_self',\n 'perspectives.use',\n 'staff.leave_requests.send',\n 'staff.my_availability.view',\n 'staff.my_availability.manage',\n 'staff.my_leave_requests.view',\n 'staff.my_leave_requests.send',\n 'planner.view',\n ])\n }\n}\n\nasync function ensureRoleAclFor(\n em: EntityManager,\n role: Role,\n tenantId: string,\n features: string[],\n options: { isSuperAdmin?: boolean; remove?: string[] } = {},\n) {\n const existing = await em.findOne(RoleAcl, { role, tenantId })\n if (!existing) {\n const acl = em.create(RoleAcl, {\n role,\n tenantId,\n featuresJson: features,\n isSuperAdmin: !!options.isSuperAdmin,\n createdAt: new Date(),\n })\n await em.persistAndFlush(acl)\n return\n }\n const currentFeatures = Array.isArray(existing.featuresJson) ? existing.featuresJson : []\n const merged = Array.from(new Set([...currentFeatures, ...features]))\n const removeSet = new Set(options.remove ?? [])\n const sanitized =\n removeSet.size\n ? merged.filter((value) => {\n if (removeSet.has(value)) return false\n for (const entry of removeSet) {\n if (entry.endsWith('.*')) {\n const prefix = entry.slice(0, -1) // keep trailing dot\n if (value === entry || value.startsWith(prefix)) return false\n }\n }\n return true\n })\n : merged\n const changed =\n sanitized.length !== currentFeatures.length ||\n sanitized.some((value, index) => value !== currentFeatures[index])\n if (changed) existing.featuresJson = sanitized\n if (options.isSuperAdmin && !existing.isSuperAdmin) {\n existing.isSuperAdmin = true\n }\n if (changed || options.isSuperAdmin) {\n await em.persistAndFlush(existing)\n }\n}\n\nasync function deactivateDemoSuperAdminIfSelfOnboardingEnabled(em: EntityManager) {\n if (process.env.SELF_SERVICE_ONBOARDING_ENABLED !== 'true') return\n try {\n const user = await em.findOne(User, { email: DEMO_SUPERADMIN_EMAIL })\n if (!user) return\n let dirty = false\n if (user.passwordHash) {\n user.passwordHash = null\n dirty = true\n }\n if (user.isConfirmed !== false) {\n user.isConfirmed = false\n dirty = true\n }\n if (dirty) {\n await em.persistAndFlush(user)\n }\n } catch (error) {\n console.error('[auth.setup] failed to deactivate demo superadmin user', error)\n }\n}\n\nasync function ensureSalesNumberingDefaults(\n em: EntityManager,\n scope: { tenantId: string; organizationId: string },\n) {\n const repo = (em as any).getRepository?.(SalesSettings)\n const findSettings = async () =>\n repo?.findOne({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n }) ??\n (em as any).findOne?.(SalesSettings, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n\n const exists = await findSettings()\n if (!exists) {\n const settings =\n repo?.create?.({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n orderNumberFormat: DEFAULT_ORDER_NUMBER_FORMAT,\n quoteNumberFormat: DEFAULT_QUOTE_NUMBER_FORMAT,\n createdAt: new Date(),\n updatedAt: new Date(),\n }) ??\n (em as any).create?.(SalesSettings, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n orderNumberFormat: DEFAULT_ORDER_NUMBER_FORMAT,\n quoteNumberFormat: DEFAULT_QUOTE_NUMBER_FORMAT,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n if (settings && (em as any).persist) {\n em.persist(settings)\n }\n }\n\n const sequenceRepo = (em as any).getRepository?.(SalesDocumentSequence)\n const kinds: Array<'order' | 'quote'> = ['order', 'quote']\n for (const kind of kinds) {\n const seq =\n sequenceRepo?.findOne({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n }) ??\n (em as any).findOne?.(SalesDocumentSequence, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n })\n if (!seq) {\n const entry =\n sequenceRepo?.create?.({\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n currentValue: 0,\n createdAt: new Date(),\n updatedAt: new Date(),\n }) ??\n (em as any).create?.(SalesDocumentSequence, {\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n documentKind: kind,\n currentValue: 0,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n if (entry && (em as any).persist) {\n em.persist(entry)\n }\n }\n }\n\n if ((em as any).flush) {\n await em.flush()\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AAErB,SAAS,MAAM,SAAS,MAAM,gBAAgB;AAC9C,SAAS,QAAQ,oBAAoB;AACrC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,SAAS,eAAe,6BAA6B;AACrD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,0BAA0B,qCAAqC;AACxE,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B;AACxC,SAAS,wBAAwB;AACjC,SAAS,mCAAmC;AAC5C,SAAS,0BAA0B;AAEnC,MAAM,qBAAqB,CAAC,YAAY,SAAS,YAAY;AAC7D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BAAI,KAAK;AAAA,QACpB,WAAW,oBAAI,KAAK;AAAA,MACtB,CAAC,KACA,GAAW,SAAS,uBAAuB;AAAA,QAC1C,UAAU,MAAM;AAAA,QAChB,gBAAgB,MAAM;AAAA,QACtB,cAAc;AAAA,QACd,cAAc;AAAA,QACd,WAAW,oBAAI,KAAK;AAAA,QACpB,WAAW,oBAAI,KAAK;AAAA,MACtB,CAAC;AACH,UAAI,SAAU,GAAW,SAAS;AAChC,WAAG,QAAQ,KAAK;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AAEA,MAAK,GAAW,OAAO;AACrB,UAAM,GAAG,MAAM;AAAA,EACjB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,9 +8,7 @@ const features = [
|
|
|
8
8
|
{ id: "sales.invoices.manage", title: "Manage sales invoices", module: "sales" },
|
|
9
9
|
{ id: "sales.credit_memos.manage", title: "Manage credit memos", module: "sales" },
|
|
10
10
|
{ id: "sales.channels.manage", title: "Manage sales channels", module: "sales" },
|
|
11
|
-
{ id: "sales.settings.manage", title: "Manage sales configuration", module: "sales" }
|
|
12
|
-
{ id: "sales.widgets.new-orders", title: "View new orders widget", module: "sales" },
|
|
13
|
-
{ id: "sales.widgets.new-quotes", title: "View new quotes widget", module: "sales" }
|
|
11
|
+
{ id: "sales.settings.manage", title: "Manage sales configuration", module: "sales" }
|
|
14
12
|
];
|
|
15
13
|
var acl_default = features;
|
|
16
14
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/sales/acl.ts"],
|
|
4
|
-
"sourcesContent": ["export const features = [\n { id: 'sales.orders.view', title: 'View sales orders', module: 'sales' },\n { id: 'sales.orders.manage', title: 'Manage sales orders', module: 'sales' },\n { id: 'sales.quotes.view', title: 'View sales quotes', module: 'sales' },\n { id: 'sales.quotes.manage', title: 'Manage sales quotes', module: 'sales' },\n { id: 'sales.shipments.manage', title: 'Manage order shipments', module: 'sales' },\n { id: 'sales.payments.manage', title: 'Manage order payments', module: 'sales' },\n { id: 'sales.invoices.manage', title: 'Manage sales invoices', module: 'sales' },\n { id: 'sales.credit_memos.manage', title: 'Manage credit memos', module: 'sales' },\n { id: 'sales.channels.manage', title: 'Manage sales channels', module: 'sales' },\n { id: 'sales.settings.manage', title: 'Manage sales configuration', module: 'sales' },\n
|
|
5
|
-
"mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,EAAE,IAAI,qBAAqB,OAAO,qBAAqB,QAAQ,QAAQ;AAAA,EACvE,EAAE,IAAI,uBAAuB,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,EAC3E,EAAE,IAAI,qBAAqB,OAAO,qBAAqB,QAAQ,QAAQ;AAAA,EACvE,EAAE,IAAI,uBAAuB,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,EAC3E,EAAE,IAAI,0BAA0B,OAAO,0BAA0B,QAAQ,QAAQ;AAAA,EACjF,EAAE,IAAI,yBAAyB,OAAO,yBAAyB,QAAQ,QAAQ;AAAA,EAC/E,EAAE,IAAI,yBAAyB,OAAO,yBAAyB,QAAQ,QAAQ;AAAA,EAC/E,EAAE,IAAI,6BAA6B,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,EACjF,EAAE,IAAI,yBAAyB,OAAO,yBAAyB,QAAQ,QAAQ;AAAA,EAC/E,EAAE,IAAI,yBAAyB,OAAO,8BAA8B,QAAQ,QAAQ;
|
|
4
|
+
"sourcesContent": ["export const features = [\n { id: 'sales.orders.view', title: 'View sales orders', module: 'sales' },\n { id: 'sales.orders.manage', title: 'Manage sales orders', module: 'sales' },\n { id: 'sales.quotes.view', title: 'View sales quotes', module: 'sales' },\n { id: 'sales.quotes.manage', title: 'Manage sales quotes', module: 'sales' },\n { id: 'sales.shipments.manage', title: 'Manage order shipments', module: 'sales' },\n { id: 'sales.payments.manage', title: 'Manage order payments', module: 'sales' },\n { id: 'sales.invoices.manage', title: 'Manage sales invoices', module: 'sales' },\n { id: 'sales.credit_memos.manage', title: 'Manage credit memos', module: 'sales' },\n { id: 'sales.channels.manage', title: 'Manage sales channels', module: 'sales' },\n { id: 'sales.settings.manage', title: 'Manage sales configuration', module: 'sales' },\n]\n\nexport default features\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,EAAE,IAAI,qBAAqB,OAAO,qBAAqB,QAAQ,QAAQ;AAAA,EACvE,EAAE,IAAI,uBAAuB,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,EAC3E,EAAE,IAAI,qBAAqB,OAAO,qBAAqB,QAAQ,QAAQ;AAAA,EACvE,EAAE,IAAI,uBAAuB,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,EAC3E,EAAE,IAAI,0BAA0B,OAAO,0BAA0B,QAAQ,QAAQ;AAAA,EACjF,EAAE,IAAI,yBAAyB,OAAO,yBAAyB,QAAQ,QAAQ;AAAA,EAC/E,EAAE,IAAI,yBAAyB,OAAO,yBAAyB,QAAQ,QAAQ;AAAA,EAC/E,EAAE,IAAI,6BAA6B,OAAO,uBAAuB,QAAQ,QAAQ;AAAA,EACjF,EAAE,IAAI,yBAAyB,OAAO,yBAAyB,QAAQ,QAAQ;AAAA,EAC/E,EAAE,IAAI,yBAAyB,OAAO,8BAA8B,QAAQ,QAAQ;AACtF;AAEA,IAAO,cAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.4.2-canary-
|
|
3
|
+
"version": "0.4.2-canary-f6b7824b47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
}
|
|
208
208
|
},
|
|
209
209
|
"dependencies": {
|
|
210
|
-
"@open-mercato/shared": "0.4.2-canary-
|
|
210
|
+
"@open-mercato/shared": "0.4.2-canary-f6b7824b47",
|
|
211
211
|
"@xyflow/react": "^12.6.0",
|
|
212
212
|
"date-fns": "^4.1.0",
|
|
213
213
|
"date-fns-tz": "^3.2.0"
|
|
@@ -38,8 +38,7 @@ export default async function ApiDocsPage() {
|
|
|
38
38
|
<code className="rounded bg-background px-2 py-0.5 text-xs text-foreground">{baseUrl}</code>
|
|
39
39
|
</p>
|
|
40
40
|
<p>
|
|
41
|
-
Run <code className="rounded bg-background px-2 py-0.5 text-xs text-foreground">
|
|
42
|
-
then <code className="rounded bg-background px-2 py-0.5 text-xs text-foreground">yarn generate</code>{' '}
|
|
41
|
+
Run <code className="rounded bg-background px-2 py-0.5 text-xs text-foreground">npm run modules:prepare</code>{' '}
|
|
43
42
|
whenever APIs change to refresh the generated registry.
|
|
44
43
|
</p>
|
|
45
44
|
</div>
|
|
@@ -379,8 +379,6 @@ async function ensureDefaultRoleAcls(
|
|
|
379
379
|
'catalog.variants.manage',
|
|
380
380
|
'catalog.pricing.manage',
|
|
381
381
|
'sales.*',
|
|
382
|
-
'sales.widgets.new-orders',
|
|
383
|
-
'sales.widgets.new-quotes',
|
|
384
382
|
'audit_logs.*',
|
|
385
383
|
'directory.organizations.view',
|
|
386
384
|
'directory.organizations.manage',
|
|
@@ -421,8 +419,6 @@ async function ensureDefaultRoleAcls(
|
|
|
421
419
|
'catalog.variants.manage',
|
|
422
420
|
'catalog.pricing.manage',
|
|
423
421
|
'sales.*',
|
|
424
|
-
'sales.widgets.new-orders',
|
|
425
|
-
'sales.widgets.new-quotes',
|
|
426
422
|
'dictionaries.view',
|
|
427
423
|
'example.*',
|
|
428
424
|
'example.widgets.*',
|
|
@@ -72,4 +72,4 @@ UI integration tips
|
|
|
72
72
|
|
|
73
73
|
Migrations
|
|
74
74
|
- Run `npm run db:migrate` after enabling modules or changing this module.
|
|
75
|
-
- Generators and module registry are updated by
|
|
75
|
+
- Generators and module registry are updated by `npm run modules:prepare`.
|
package/src/modules/sales/acl.ts
CHANGED
|
@@ -9,8 +9,6 @@ export const features = [
|
|
|
9
9
|
{ id: 'sales.credit_memos.manage', title: 'Manage credit memos', module: 'sales' },
|
|
10
10
|
{ id: 'sales.channels.manage', title: 'Manage sales channels', module: 'sales' },
|
|
11
11
|
{ id: 'sales.settings.manage', title: 'Manage sales configuration', module: 'sales' },
|
|
12
|
-
{ id: 'sales.widgets.new-orders', title: 'View new orders widget', module: 'sales' },
|
|
13
|
-
{ id: 'sales.widgets.new-quotes', title: 'View new quotes widget', module: 'sales' },
|
|
14
12
|
]
|
|
15
13
|
|
|
16
14
|
export default features
|
|
@@ -1534,36 +1534,5 @@
|
|
|
1534
1534
|
"sales.search.badge.deliveryWindow": "Lieferfenster",
|
|
1535
1535
|
"sales.search.badge.paymentMethod": "Zahlungsart",
|
|
1536
1536
|
"sales.search.badge.taxRate": "Steuersatz",
|
|
1537
|
-
"sales.search.badge.documentTag": "Dokumenten-Tag"
|
|
1538
|
-
"sales.errors.invalid_query": "Ungültige Abfrageparameter",
|
|
1539
|
-
"sales.errors.tenant_required": "Mandantenkontext ist erforderlich",
|
|
1540
|
-
"sales.errors.organization_required": "Organisationskontext ist erforderlich",
|
|
1541
|
-
"sales.errors.unauthorized": "Nicht autorisiert",
|
|
1542
|
-
"sales.errors.invalid_date": "Ungültiger Datumsbereich",
|
|
1543
|
-
"sales.widgets.newOrders.error": "Bestellungen konnten nicht geladen werden",
|
|
1544
|
-
"sales.widgets.newOrders.empty": "Keine Bestellungen in diesem Zeitraum gefunden",
|
|
1545
|
-
"sales.widgets.newOrders.noCustomer": "Kein Kunde",
|
|
1546
|
-
"sales.widgets.newOrders.unknownDate": "Unbekanntes Datum",
|
|
1547
|
-
"sales.widgets.newOrders.settings.pageSize": "Anzahl der Bestellungen",
|
|
1548
|
-
"sales.widgets.newOrders.settings.datePeriod": "Zeitraum",
|
|
1549
|
-
"sales.widgets.newOrders.settings.last24h": "Letzte 24 Stunden",
|
|
1550
|
-
"sales.widgets.newOrders.settings.last7d": "Letzte 7 Tage",
|
|
1551
|
-
"sales.widgets.newOrders.settings.last30d": "Letzte 30 Tage",
|
|
1552
|
-
"sales.widgets.newOrders.settings.custom": "Benutzerdefinierter Zeitraum",
|
|
1553
|
-
"sales.widgets.newOrders.settings.customFrom": "Von",
|
|
1554
|
-
"sales.widgets.newOrders.settings.customTo": "Bis",
|
|
1555
|
-
"sales.widgets.newQuotes.error": "Angebote konnten nicht geladen werden",
|
|
1556
|
-
"sales.widgets.newQuotes.empty": "Keine Angebote in diesem Zeitraum gefunden",
|
|
1557
|
-
"sales.widgets.newQuotes.noCustomer": "Kein Kunde",
|
|
1558
|
-
"sales.widgets.newQuotes.validUntil": "Gültig bis {{date}}",
|
|
1559
|
-
"sales.widgets.newQuotes.converted": "Konvertiert",
|
|
1560
|
-
"sales.widgets.newQuotes.unknownDate": "Unbekanntes Datum",
|
|
1561
|
-
"sales.widgets.newQuotes.settings.pageSize": "Anzahl der Angebote",
|
|
1562
|
-
"sales.widgets.newQuotes.settings.datePeriod": "Zeitraum",
|
|
1563
|
-
"sales.widgets.newQuotes.settings.last24h": "Letzte 24 Stunden",
|
|
1564
|
-
"sales.widgets.newQuotes.settings.last7d": "Letzte 7 Tage",
|
|
1565
|
-
"sales.widgets.newQuotes.settings.last30d": "Letzte 30 Tage",
|
|
1566
|
-
"sales.widgets.newQuotes.settings.custom": "Benutzerdefinierter Zeitraum",
|
|
1567
|
-
"sales.widgets.newQuotes.settings.customFrom": "Von",
|
|
1568
|
-
"sales.widgets.newQuotes.settings.customTo": "Bis"
|
|
1537
|
+
"sales.search.badge.documentTag": "Dokumenten-Tag"
|
|
1569
1538
|
}
|
|
@@ -1516,36 +1516,5 @@
|
|
|
1516
1516
|
"sales.search.badge.deliveryWindow": "Delivery window",
|
|
1517
1517
|
"sales.search.badge.paymentMethod": "Payment method",
|
|
1518
1518
|
"sales.search.badge.taxRate": "Tax rate",
|
|
1519
|
-
"sales.search.badge.documentTag": "Document tag"
|
|
1520
|
-
"sales.errors.invalid_query": "Invalid query parameters",
|
|
1521
|
-
"sales.errors.tenant_required": "Tenant context is required",
|
|
1522
|
-
"sales.errors.organization_required": "Organization context is required",
|
|
1523
|
-
"sales.errors.unauthorized": "Unauthorized",
|
|
1524
|
-
"sales.errors.invalid_date": "Invalid date range",
|
|
1525
|
-
"sales.widgets.newOrders.error": "Failed to load orders",
|
|
1526
|
-
"sales.widgets.newOrders.empty": "No orders found in this period",
|
|
1527
|
-
"sales.widgets.newOrders.noCustomer": "No customer",
|
|
1528
|
-
"sales.widgets.newOrders.unknownDate": "Unknown date",
|
|
1529
|
-
"sales.widgets.newOrders.settings.pageSize": "Number of Orders",
|
|
1530
|
-
"sales.widgets.newOrders.settings.datePeriod": "Date Period",
|
|
1531
|
-
"sales.widgets.newOrders.settings.last24h": "Last 24 hours",
|
|
1532
|
-
"sales.widgets.newOrders.settings.last7d": "Last 7 days",
|
|
1533
|
-
"sales.widgets.newOrders.settings.last30d": "Last 30 days",
|
|
1534
|
-
"sales.widgets.newOrders.settings.custom": "Custom range",
|
|
1535
|
-
"sales.widgets.newOrders.settings.customFrom": "From",
|
|
1536
|
-
"sales.widgets.newOrders.settings.customTo": "To",
|
|
1537
|
-
"sales.widgets.newQuotes.error": "Failed to load quotes",
|
|
1538
|
-
"sales.widgets.newQuotes.empty": "No quotes found in this period",
|
|
1539
|
-
"sales.widgets.newQuotes.noCustomer": "No customer",
|
|
1540
|
-
"sales.widgets.newQuotes.validUntil": "Valid until {{date}}",
|
|
1541
|
-
"sales.widgets.newQuotes.converted": "Converted",
|
|
1542
|
-
"sales.widgets.newQuotes.unknownDate": "Unknown date",
|
|
1543
|
-
"sales.widgets.newQuotes.settings.pageSize": "Number of Quotes",
|
|
1544
|
-
"sales.widgets.newQuotes.settings.datePeriod": "Date Period",
|
|
1545
|
-
"sales.widgets.newQuotes.settings.last24h": "Last 24 hours",
|
|
1546
|
-
"sales.widgets.newQuotes.settings.last7d": "Last 7 days",
|
|
1547
|
-
"sales.widgets.newQuotes.settings.last30d": "Last 30 days",
|
|
1548
|
-
"sales.widgets.newQuotes.settings.custom": "Custom range",
|
|
1549
|
-
"sales.widgets.newQuotes.settings.customFrom": "From",
|
|
1550
|
-
"sales.widgets.newQuotes.settings.customTo": "To"
|
|
1519
|
+
"sales.search.badge.documentTag": "Document tag"
|
|
1551
1520
|
}
|
|
@@ -1517,36 +1517,5 @@
|
|
|
1517
1517
|
"sales.search.badge.deliveryWindow": "Ventana de entrega",
|
|
1518
1518
|
"sales.search.badge.paymentMethod": "Método de pago",
|
|
1519
1519
|
"sales.search.badge.taxRate": "Tasa de impuesto",
|
|
1520
|
-
"sales.search.badge.documentTag": "Etiqueta de documento"
|
|
1521
|
-
"sales.errors.invalid_query": "Parámetros de consulta inválidos",
|
|
1522
|
-
"sales.errors.tenant_required": "Se requiere el contexto del inquilino",
|
|
1523
|
-
"sales.errors.organization_required": "Se requiere el contexto de la organización",
|
|
1524
|
-
"sales.errors.unauthorized": "No autorizado",
|
|
1525
|
-
"sales.errors.invalid_date": "Rango de fechas inválido",
|
|
1526
|
-
"sales.widgets.newOrders.error": "No se pudieron cargar los pedidos",
|
|
1527
|
-
"sales.widgets.newOrders.empty": "No se encontraron pedidos en este período",
|
|
1528
|
-
"sales.widgets.newOrders.noCustomer": "Sin cliente",
|
|
1529
|
-
"sales.widgets.newOrders.unknownDate": "Fecha desconocida",
|
|
1530
|
-
"sales.widgets.newOrders.settings.pageSize": "Número de pedidos",
|
|
1531
|
-
"sales.widgets.newOrders.settings.datePeriod": "Período",
|
|
1532
|
-
"sales.widgets.newOrders.settings.last24h": "Últimas 24 horas",
|
|
1533
|
-
"sales.widgets.newOrders.settings.last7d": "Últimos 7 días",
|
|
1534
|
-
"sales.widgets.newOrders.settings.last30d": "Últimos 30 días",
|
|
1535
|
-
"sales.widgets.newOrders.settings.custom": "Rango personalizado",
|
|
1536
|
-
"sales.widgets.newOrders.settings.customFrom": "Desde",
|
|
1537
|
-
"sales.widgets.newOrders.settings.customTo": "Hasta",
|
|
1538
|
-
"sales.widgets.newQuotes.error": "No se pudieron cargar las cotizaciones",
|
|
1539
|
-
"sales.widgets.newQuotes.empty": "No se encontraron cotizaciones en este período",
|
|
1540
|
-
"sales.widgets.newQuotes.noCustomer": "Sin cliente",
|
|
1541
|
-
"sales.widgets.newQuotes.validUntil": "Válido hasta {{date}}",
|
|
1542
|
-
"sales.widgets.newQuotes.converted": "Convertido",
|
|
1543
|
-
"sales.widgets.newQuotes.unknownDate": "Fecha desconocida",
|
|
1544
|
-
"sales.widgets.newQuotes.settings.pageSize": "Número de cotizaciones",
|
|
1545
|
-
"sales.widgets.newQuotes.settings.datePeriod": "Período",
|
|
1546
|
-
"sales.widgets.newQuotes.settings.last24h": "Últimas 24 horas",
|
|
1547
|
-
"sales.widgets.newQuotes.settings.last7d": "Últimos 7 días",
|
|
1548
|
-
"sales.widgets.newQuotes.settings.last30d": "Últimos 30 días",
|
|
1549
|
-
"sales.widgets.newQuotes.settings.custom": "Rango personalizado",
|
|
1550
|
-
"sales.widgets.newQuotes.settings.customFrom": "Desde",
|
|
1551
|
-
"sales.widgets.newQuotes.settings.customTo": "Hasta"
|
|
1520
|
+
"sales.search.badge.documentTag": "Etiqueta de documento"
|
|
1552
1521
|
}
|
|
@@ -1532,36 +1532,5 @@
|
|
|
1532
1532
|
"sales.search.badge.deliveryWindow": "Okno dostawy",
|
|
1533
1533
|
"sales.search.badge.paymentMethod": "Metoda płatności",
|
|
1534
1534
|
"sales.search.badge.taxRate": "Stawka podatku",
|
|
1535
|
-
"sales.search.badge.documentTag": "Tag dokumentu"
|
|
1536
|
-
"sales.errors.invalid_query": "Nieprawidłowe parametry zapytania",
|
|
1537
|
-
"sales.errors.tenant_required": "Wymagany kontekst najemcy",
|
|
1538
|
-
"sales.errors.organization_required": "Wymagany kontekst organizacji",
|
|
1539
|
-
"sales.errors.unauthorized": "Brak autoryzacji",
|
|
1540
|
-
"sales.errors.invalid_date": "Nieprawidłowy zakres dat",
|
|
1541
|
-
"sales.widgets.newOrders.error": "Nie udało się wczytać zamówień",
|
|
1542
|
-
"sales.widgets.newOrders.empty": "Brak zamówień w tym okresie",
|
|
1543
|
-
"sales.widgets.newOrders.noCustomer": "Brak klienta",
|
|
1544
|
-
"sales.widgets.newOrders.unknownDate": "Nieznana data",
|
|
1545
|
-
"sales.widgets.newOrders.settings.pageSize": "Liczba zamówień",
|
|
1546
|
-
"sales.widgets.newOrders.settings.datePeriod": "Okres",
|
|
1547
|
-
"sales.widgets.newOrders.settings.last24h": "Ostatnie 24 godziny",
|
|
1548
|
-
"sales.widgets.newOrders.settings.last7d": "Ostatnie 7 dni",
|
|
1549
|
-
"sales.widgets.newOrders.settings.last30d": "Ostatnie 30 dni",
|
|
1550
|
-
"sales.widgets.newOrders.settings.custom": "Zakres niestandardowy",
|
|
1551
|
-
"sales.widgets.newOrders.settings.customFrom": "Od",
|
|
1552
|
-
"sales.widgets.newOrders.settings.customTo": "Do",
|
|
1553
|
-
"sales.widgets.newQuotes.error": "Nie udało się wczytać ofert",
|
|
1554
|
-
"sales.widgets.newQuotes.empty": "Brak ofert w tym okresie",
|
|
1555
|
-
"sales.widgets.newQuotes.noCustomer": "Brak klienta",
|
|
1556
|
-
"sales.widgets.newQuotes.validUntil": "Ważne do {{date}}",
|
|
1557
|
-
"sales.widgets.newQuotes.converted": "Przekształcona",
|
|
1558
|
-
"sales.widgets.newQuotes.unknownDate": "Nieznana data",
|
|
1559
|
-
"sales.widgets.newQuotes.settings.pageSize": "Liczba ofert",
|
|
1560
|
-
"sales.widgets.newQuotes.settings.datePeriod": "Okres",
|
|
1561
|
-
"sales.widgets.newQuotes.settings.last24h": "Ostatnie 24 godziny",
|
|
1562
|
-
"sales.widgets.newQuotes.settings.last7d": "Ostatnie 7 dni",
|
|
1563
|
-
"sales.widgets.newQuotes.settings.last30d": "Ostatnie 30 dni",
|
|
1564
|
-
"sales.widgets.newQuotes.settings.custom": "Zakres niestandardowy",
|
|
1565
|
-
"sales.widgets.newQuotes.settings.customFrom": "Od",
|
|
1566
|
-
"sales.widgets.newQuotes.settings.customTo": "Do"
|
|
1535
|
+
"sales.search.badge.documentTag": "Tag dokumentu"
|
|
1567
1536
|
}
|