@nocobase/app-server 5.0.0-beta.4 → 5.0.0-beta.5
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/id-generator/provider.d.ts +1 -0
- package/dist/id-generator/provider.d.ts.map +1 -1
- package/dist/id-generator/provider.js +25 -4
- package/dist/id-generator/provider.js.map +1 -1
- package/dist/id-generator/token.d.ts +7 -0
- package/dist/id-generator/token.d.ts.map +1 -1
- package/dist/id-generator/token.js +2 -0
- package/dist/id-generator/token.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/id-generator/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/id-generator/provider.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAIhE,qBAAa,mBAAoB,SAAQ,eAAe,CAAC,oBAAoB,CAAC;IAC5E,SAAgB,IAAI,EAAE,MAAM,CAAuC;IAEnD,QAAQ,IAAI,IAAI;IAoBV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAO5C"}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
import { SnowflakeIdGenerator } from '@nocobase/snowflake';
|
|
1
|
+
import { SnowflakeIdGenerator, } from '@nocobase/snowflake';
|
|
2
2
|
import { ServiceProvider } from '@nocobase/service-provider';
|
|
3
|
-
import { idGeneratorToken } from './token.js';
|
|
3
|
+
import { idGeneratorImplementationToken, idGeneratorToken } from './token.js';
|
|
4
4
|
export class IdGeneratorProvider extends ServiceProvider {
|
|
5
5
|
name = '@nocobase/app-server/id-generator';
|
|
6
6
|
register() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
this.app.container.singleton(idGeneratorToken, (resolver) => {
|
|
8
|
+
let selected;
|
|
9
|
+
const implementation = () => {
|
|
10
|
+
if (selected)
|
|
11
|
+
return selected;
|
|
12
|
+
// Select on first generation, not when an earlier provider resolves the service.
|
|
13
|
+
selected = resolver.has(idGeneratorImplementationToken)
|
|
14
|
+
? resolver.resolve(idGeneratorImplementationToken)
|
|
15
|
+
: new SnowflakeIdGenerator(this.app.config.get('snowflake'));
|
|
16
|
+
return selected;
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
generate: () => implementation().generate(),
|
|
20
|
+
generateString: () => implementation().generateString(),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
async boot() {
|
|
25
|
+
if (this.app.container.has(idGeneratorImplementationToken)) {
|
|
26
|
+
await this.app.container
|
|
27
|
+
.resolve(idGeneratorImplementationToken)
|
|
28
|
+
.initialize();
|
|
29
|
+
}
|
|
9
30
|
}
|
|
10
31
|
}
|
|
11
32
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/id-generator/provider.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/id-generator/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAI7D,OAAO,EAAE,8BAA8B,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9E,MAAM,OAAO,mBAAoB,SAAQ,eAAqC;IAC5D,IAAI,GAAW,mCAAmC,CAAC;IAEnD,QAAQ;QACtB,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC1D,IAAI,QAAwC,CAAC;YAC7C,MAAM,cAAc,GAAG,GAAuB,EAAE;gBAC9C,IAAI,QAAQ;oBAAE,OAAO,QAAQ,CAAC;gBAC9B,iFAAiF;gBACjF,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,8BAA8B,CAAC;oBACrD,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,8BAA8B,CAAC;oBAClD,CAAC,CAAC,IAAI,oBAAoB,CACtB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAA6B,WAAW,CAAE,CAC9D,CAAC;gBACN,OAAO,QAAQ,CAAC;YAClB,CAAC,CAAC;YACF,OAAO;gBACL,QAAQ,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE;gBAC3C,cAAc,EAAE,GAAG,EAAE,CAAC,cAAc,EAAE,CAAC,cAAc,EAAE;aACxD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEe,KAAK,CAAC,IAAI;QACxB,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,8BAA8B,CAAC,EAAE,CAAC;YAC3D,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS;iBACrB,OAAO,CAAC,8BAA8B,CAAC;iBACvC,UAAU,EAAE,CAAC;QAClB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { type ServiceToken } from '@nocobase/service-provider';
|
|
2
2
|
import type { IdGeneratorService } from '@nocobase/snowflake';
|
|
3
3
|
export declare const idGeneratorToken: ServiceToken<IdGeneratorService>;
|
|
4
|
+
/** Optional synchronous ID implementation, initialized before consumers boot. */
|
|
5
|
+
export interface IdGeneratorImplementation extends IdGeneratorService {
|
|
6
|
+
/** May share a sticky initialization promise with an earlier database task hook. */
|
|
7
|
+
initialize(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** Register at most one implementation per application, during provider registration. */
|
|
10
|
+
export declare const idGeneratorImplementationToken: ServiceToken<IdGeneratorImplementation>;
|
|
4
11
|
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/id-generator/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,kBAAkB,CACC,CAAC"}
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/id-generator/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,gBAAgB,EAAE,YAAY,CAAC,kBAAkB,CACC,CAAC;AAEhE,iFAAiF;AACjF,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE,oFAAoF;IACpF,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED,yFAAyF;AACzF,eAAO,MAAM,8BAA8B,EAAE,YAAY,CAAC,yBAAyB,CAGhF,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { createServiceToken, } from '@nocobase/service-provider';
|
|
2
2
|
export const idGeneratorToken = createServiceToken('@nocobase/snowflake');
|
|
3
|
+
/** Register at most one implementation per application, during provider registration. */
|
|
4
|
+
export const idGeneratorImplementationToken = createServiceToken('@nocobase/app-server/id-generator/implementation');
|
|
3
5
|
//# sourceMappingURL=token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/id-generator/token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,CAAC,MAAM,gBAAgB,GAC3B,kBAAkB,CAAqB,qBAAqB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/id-generator/token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,CAAC,MAAM,gBAAgB,GAC3B,kBAAkB,CAAqB,qBAAqB,CAAC,CAAC;AAQhE,yFAAyF;AACzF,MAAM,CAAC,MAAM,8BAA8B,GACzC,kBAAkB,CAChB,kDAAkD,CACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/app-server",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"prettier": "@nocobase/dev-config/prettier",
|
|
6
6
|
"engines": {
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"hono": "^4.13.2",
|
|
120
120
|
"@standard-schema/spec": "^1.0.0",
|
|
121
121
|
"hono-openapi": "^1.3.3",
|
|
122
|
-
"zod": "^4.6.
|
|
122
|
+
"zod": "^4.6.6",
|
|
123
123
|
"openapi-types": "^12.1.3",
|
|
124
124
|
"@nocobase/app-websocket": "^0.1.0-beta.1",
|
|
125
125
|
"@nocobase/config": "^0.1.0-beta.3",
|