@servora/proto-utils 0.0.2 → 0.1.1

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 (116) hide show
  1. package/dist/client/errors.d.ts +32 -0
  2. package/dist/client/errors.d.ts.map +1 -0
  3. package/dist/client/errors.js +37 -0
  4. package/dist/client/errors.js.map +1 -0
  5. package/dist/client/index.d.ts +3 -0
  6. package/dist/client/index.d.ts.map +1 -0
  7. package/dist/client/index.js +3 -0
  8. package/dist/client/index.js.map +1 -0
  9. package/dist/client/request.d.ts +54 -0
  10. package/dist/client/request.d.ts.map +1 -0
  11. package/dist/client/request.js +149 -0
  12. package/dist/client/request.js.map +1 -0
  13. package/dist/gen/servora/audit/v1/index.d.ts +26 -0
  14. package/dist/gen/servora/audit/v1/index.d.ts.map +1 -0
  15. package/dist/gen/servora/audit/v1/index.js +6 -0
  16. package/dist/gen/servora/audit/v1/index.js.map +1 -0
  17. package/dist/gen/servora/authn/v1/index.d.ts +6 -0
  18. package/dist/gen/servora/authn/v1/index.d.ts.map +1 -0
  19. package/dist/gen/servora/authn/v1/index.js +6 -0
  20. package/dist/gen/servora/authn/v1/index.js.map +1 -0
  21. package/dist/gen/servora/authz/v1/index.d.ts +8 -0
  22. package/dist/gen/servora/authz/v1/index.d.ts.map +1 -0
  23. package/dist/gen/servora/authz/v1/index.js +6 -0
  24. package/dist/gen/servora/authz/v1/index.js.map +1 -0
  25. package/dist/gen/servora/cloudevents/v1/index.d.ts +31 -0
  26. package/dist/gen/servora/cloudevents/v1/index.d.ts.map +1 -0
  27. package/dist/gen/servora/cloudevents/v1/index.js +6 -0
  28. package/dist/gen/servora/cloudevents/v1/index.js.map +1 -0
  29. package/dist/gen/servora/conf/v1/index.d.ts +9 -0
  30. package/dist/gen/servora/conf/v1/index.d.ts.map +1 -0
  31. package/dist/gen/servora/conf/v1/index.js +6 -0
  32. package/dist/gen/servora/conf/v1/index.js.map +1 -0
  33. package/dist/gen/servora/core/v1/index.d.ts +157 -0
  34. package/dist/gen/servora/core/v1/index.d.ts.map +1 -0
  35. package/dist/gen/servora/core/v1/index.js +6 -0
  36. package/dist/gen/servora/core/v1/index.js.map +1 -0
  37. package/dist/gen/servora/infra/db/clickhouse/v1/index.d.ts +22 -0
  38. package/dist/gen/servora/infra/db/clickhouse/v1/index.d.ts.map +1 -0
  39. package/dist/gen/servora/infra/db/clickhouse/v1/index.js +6 -0
  40. package/dist/gen/servora/infra/db/clickhouse/v1/index.js.map +1 -0
  41. package/dist/gen/servora/infra/kafka/v1/index.d.ts +28 -0
  42. package/dist/gen/servora/infra/kafka/v1/index.d.ts.map +1 -0
  43. package/dist/gen/servora/infra/kafka/v1/index.js +6 -0
  44. package/dist/gen/servora/infra/kafka/v1/index.js.map +1 -0
  45. package/dist/gen/servora/infra/mail/v1/index.d.ts +20 -0
  46. package/dist/gen/servora/infra/mail/v1/index.d.ts.map +1 -0
  47. package/dist/gen/servora/infra/mail/v1/index.js +6 -0
  48. package/dist/gen/servora/infra/mail/v1/index.js.map +1 -0
  49. package/dist/gen/servora/infra/redis/v1/index.d.ts +13 -0
  50. package/dist/gen/servora/infra/redis/v1/index.d.ts.map +1 -0
  51. package/dist/gen/servora/infra/redis/v1/index.js +6 -0
  52. package/dist/gen/servora/infra/redis/v1/index.js.map +1 -0
  53. package/dist/gen/servora/mapper/v1/index.d.ts +7 -0
  54. package/dist/gen/servora/mapper/v1/index.d.ts.map +1 -0
  55. package/dist/gen/servora/mapper/v1/index.js +6 -0
  56. package/dist/gen/servora/mapper/v1/index.js.map +1 -0
  57. package/dist/gen/servora/obs/audit/v1/index.d.ts +7 -0
  58. package/dist/gen/servora/obs/audit/v1/index.d.ts.map +1 -0
  59. package/dist/gen/servora/obs/audit/v1/index.js +6 -0
  60. package/dist/gen/servora/obs/audit/v1/index.js.map +1 -0
  61. package/dist/gen/servora/pagination/v1/index.d.ts +26 -0
  62. package/dist/gen/servora/pagination/v1/index.d.ts.map +1 -0
  63. package/dist/gen/servora/pagination/v1/index.js +6 -0
  64. package/dist/gen/servora/pagination/v1/index.js.map +1 -0
  65. package/dist/gen/servora/security/authn/oidc/v1/index.d.ts +7 -0
  66. package/dist/gen/servora/security/authn/oidc/v1/index.d.ts.map +1 -0
  67. package/dist/gen/servora/security/authn/oidc/v1/index.js +6 -0
  68. package/dist/gen/servora/security/authn/oidc/v1/index.js.map +1 -0
  69. package/dist/gen/servora/security/authz/openfga/v1/index.d.ts +7 -0
  70. package/dist/gen/servora/security/authz/openfga/v1/index.d.ts.map +1 -0
  71. package/dist/gen/servora/security/authz/openfga/v1/index.js +6 -0
  72. package/dist/gen/servora/security/authz/openfga/v1/index.js.map +1 -0
  73. package/dist/gen/servora/security/jwt/v1/index.d.ts +9 -0
  74. package/dist/gen/servora/security/jwt/v1/index.d.ts.map +1 -0
  75. package/dist/gen/servora/security/jwt/v1/index.js +6 -0
  76. package/dist/gen/servora/security/jwt/v1/index.js.map +1 -0
  77. package/dist/gen/servora/security/tls/v1/index.d.ts +7 -0
  78. package/dist/gen/servora/security/tls/v1/index.d.ts.map +1 -0
  79. package/dist/gen/servora/security/tls/v1/index.js +6 -0
  80. package/dist/gen/servora/security/tls/v1/index.js.map +1 -0
  81. package/dist/gen/servora/transport/http/cors/v1/index.d.ts +12 -0
  82. package/dist/gen/servora/transport/http/cors/v1/index.d.ts.map +1 -0
  83. package/dist/gen/servora/transport/http/cors/v1/index.js +6 -0
  84. package/dist/gen/servora/transport/http/cors/v1/index.js.map +1 -0
  85. package/dist/index.d.ts +3 -0
  86. package/dist/index.d.ts.map +1 -0
  87. package/dist/index.js +3 -0
  88. package/dist/index.js.map +1 -0
  89. package/dist/query.d.ts +1 -0
  90. package/dist/query.d.ts.map +1 -1
  91. package/dist/query.js +8 -6
  92. package/dist/query.js.map +1 -1
  93. package/package.json +37 -6
  94. package/src/client/errors.ts +54 -0
  95. package/src/client/index.ts +2 -0
  96. package/src/client/request.ts +233 -0
  97. package/src/gen/servora/audit/v1/index.ts +64 -0
  98. package/src/gen/servora/authn/v1/index.ts +25 -0
  99. package/src/gen/servora/authz/v1/index.ts +28 -0
  100. package/src/gen/servora/cloudevents/v1/index.ts +49 -0
  101. package/src/gen/servora/conf/v1/index.ts +32 -0
  102. package/src/gen/servora/core/v1/index.ts +221 -0
  103. package/src/gen/servora/infra/db/clickhouse/v1/index.ts +33 -0
  104. package/src/gen/servora/infra/kafka/v1/index.ts +41 -0
  105. package/src/gen/servora/infra/mail/v1/index.ts +32 -0
  106. package/src/gen/servora/infra/redis/v1/index.ts +23 -0
  107. package/src/gen/servora/mapper/v1/index.ts +18 -0
  108. package/src/gen/servora/obs/audit/v1/index.ts +13 -0
  109. package/src/gen/servora/pagination/v1/index.ts +37 -0
  110. package/src/gen/servora/security/authn/oidc/v1/index.ts +13 -0
  111. package/src/gen/servora/security/authz/openfga/v1/index.ts +13 -0
  112. package/src/gen/servora/security/jwt/v1/index.ts +17 -0
  113. package/src/gen/servora/security/tls/v1/index.ts +13 -0
  114. package/src/gen/servora/transport/http/cors/v1/index.ts +22 -0
  115. package/src/index.ts +2 -0
  116. package/src/query.ts +13 -11
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/gen/servora/core/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AA0Nd,gDAAgD"}
@@ -0,0 +1,22 @@
1
+ export type ClickHouse = {
2
+ addrs: string[] | undefined;
3
+ database: string | undefined;
4
+ username: string | undefined;
5
+ password: string | undefined;
6
+ dialTimeout: wellKnownDuration | undefined;
7
+ readTimeout: wellKnownDuration | undefined;
8
+ maxOpenConns: number | undefined;
9
+ maxIdleConns: number | undefined;
10
+ connMaxLifetime: wellKnownDuration | undefined;
11
+ tls: servorasecuritytlsv1_TLS | undefined;
12
+ compression: string | undefined;
13
+ };
14
+ type wellKnownDuration = string;
15
+ export type servorasecuritytlsv1_TLS = {
16
+ enable: boolean | undefined;
17
+ certPath: string | undefined;
18
+ keyPath: string | undefined;
19
+ caPath: string | undefined;
20
+ };
21
+ export {};
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/servora/infra/db/clickhouse/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,eAAe,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC/C,GAAG,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAMF,KAAK,iBAAiB,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/gen/servora/infra/db/clickhouse/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AA8Bd,gDAAgD"}
@@ -0,0 +1,28 @@
1
+ export type Kafka = {
2
+ brokers: string[] | undefined;
3
+ clientId: string | undefined;
4
+ consumerGroup: string | undefined;
5
+ requiredAcks: number | undefined;
6
+ retryMax: number | undefined;
7
+ retryBackoff: wellKnownDuration | undefined;
8
+ dialTimeout: wellKnownDuration | undefined;
9
+ readTimeout: wellKnownDuration | undefined;
10
+ writeTimeout: wellKnownDuration | undefined;
11
+ compression: string | undefined;
12
+ tls: servorasecuritytlsv1_TLS | undefined;
13
+ sasl: Kafka_SASL | undefined;
14
+ };
15
+ type wellKnownDuration = string;
16
+ export type servorasecuritytlsv1_TLS = {
17
+ enable: boolean | undefined;
18
+ certPath: string | undefined;
19
+ keyPath: string | undefined;
20
+ caPath: string | undefined;
21
+ };
22
+ export type Kafka_SASL = {
23
+ mechanism: string | undefined;
24
+ username: string | undefined;
25
+ password: string | undefined;
26
+ };
27
+ export {};
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/gen/servora/infra/kafka/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,GAAG,EAAE,wBAAwB,GAAG,SAAS,CAAC;IAC1C,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9B,CAAC;AAMF,KAAK,iBAAiB,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/gen/servora/infra/kafka/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAsCd,gDAAgD"}
@@ -0,0 +1,20 @@
1
+ export type Mail = {
2
+ smtp: SMTP | undefined;
3
+ from: MailFrom | undefined;
4
+ };
5
+ export type SMTP = {
6
+ host: string | undefined;
7
+ port: number | undefined;
8
+ username: string | undefined;
9
+ password: string | undefined;
10
+ tls: boolean | undefined;
11
+ skipVerifySsl: boolean | undefined;
12
+ sendTimeout: wellKnownDuration | undefined;
13
+ };
14
+ type wellKnownDuration = string;
15
+ export type MailFrom = {
16
+ address: string | undefined;
17
+ name: string | undefined;
18
+ };
19
+ export {};
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/gen/servora/infra/mail/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC;IACzB,aAAa,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC5C,CAAC;AAMF,KAAK,iBAAiB,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/gen/servora/infra/mail/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AA6Bd,gDAAgD"}
@@ -0,0 +1,13 @@
1
+ export type Redis = {
2
+ network: string | undefined;
3
+ addr: string | undefined;
4
+ userName: string | undefined;
5
+ password: string | undefined;
6
+ db: number | undefined;
7
+ dialTimeout: wellKnownDuration | undefined;
8
+ readTimeout: wellKnownDuration | undefined;
9
+ writeTimeout: wellKnownDuration | undefined;
10
+ };
11
+ type wellKnownDuration = string;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/gen/servora/infra/redis/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,WAAW,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,YAAY,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC7C,CAAC;AAMF,KAAK,iBAAiB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/gen/servora/infra/redis/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAoBd,gDAAgD"}
@@ -0,0 +1,7 @@
1
+ export type MapperRule = {
2
+ ignoreRead: string[] | undefined;
3
+ };
4
+ export type MapperFieldRule = {
5
+ rename: string | undefined;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/gen/servora/mapper/v1/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG;IAEvB,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAClC,CAAC;AAGF,MAAM,MAAM,eAAe,GAAG;IAE5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/gen/servora/mapper/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAed,gDAAgD"}
@@ -0,0 +1,7 @@
1
+ export type AuditContract = {
2
+ enabled: boolean | undefined;
3
+ emitterType: string | undefined;
4
+ topic: string | undefined;
5
+ serviceName: string | undefined;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/gen/servora/obs/audit/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/gen/servora/obs/audit/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAUd,gDAAgD"}
@@ -0,0 +1,26 @@
1
+ export type PagePaginationRequest = {
2
+ page: number | undefined;
3
+ pageSize: number | undefined;
4
+ };
5
+ export type CursorPaginationRequest = {
6
+ cursor: string | undefined;
7
+ limit: number | undefined;
8
+ };
9
+ export type PaginationRequest = {
10
+ page?: PagePaginationRequest;
11
+ cursor?: CursorPaginationRequest;
12
+ };
13
+ export type PagePaginationResponse = {
14
+ total: number | undefined;
15
+ page: number | undefined;
16
+ pageSize: number | undefined;
17
+ };
18
+ export type CursorPaginationResponse = {
19
+ nextCursor: string | undefined;
20
+ hasMore: boolean | undefined;
21
+ };
22
+ export type PaginationResponse = {
23
+ page?: PagePaginationResponse;
24
+ cursor?: CursorPaginationResponse;
25
+ };
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/gen/servora/pagination/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,MAAM,CAAC,EAAE,wBAAwB,CAAC;CACnC,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/gen/servora/pagination/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAkCd,gDAAgD"}
@@ -0,0 +1,7 @@
1
+ export type Config = {
2
+ cryptoKey: string | undefined;
3
+ grantTypeRefreshToken: boolean | undefined;
4
+ defaultLogoutRedirectUri: string | undefined;
5
+ loginBaseUrl: string | undefined;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/servora/security/authn/oidc/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,MAAM,GAAG;IACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/gen/servora/security/authn/oidc/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAUd,gDAAgD"}
@@ -0,0 +1,7 @@
1
+ export type Config = {
2
+ apiUrl: string | undefined;
3
+ storeId: string | undefined;
4
+ modelId: string | undefined;
5
+ apiToken: string | undefined;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/servora/security/authz/openfga/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/gen/servora/security/authz/openfga/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAUd,gDAAgD"}
@@ -0,0 +1,9 @@
1
+ export type Jwt = {
2
+ privateKeyPath: string | undefined;
3
+ privateKeyPem: string | undefined;
4
+ accessExpire: number | undefined;
5
+ refreshExpire: number | undefined;
6
+ issuer: string | undefined;
7
+ audience: string | undefined;
8
+ };
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/gen/servora/security/jwt/v1/index.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAG,GAAG;IAChB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/gen/servora/security/jwt/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAcd,gDAAgD"}
@@ -0,0 +1,7 @@
1
+ export type TLS = {
2
+ enable: boolean | undefined;
3
+ certPath: string | undefined;
4
+ keyPath: string | undefined;
5
+ caPath: string | undefined;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/gen/servora/security/tls/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAG,GAAG;IAChB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/gen/servora/security/tls/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAUd,gDAAgD"}
@@ -0,0 +1,12 @@
1
+ export type CORS = {
2
+ enable: boolean | undefined;
3
+ allowedOrigins: string[] | undefined;
4
+ allowedMethods: string[] | undefined;
5
+ allowedHeaders: string[] | undefined;
6
+ exposedHeaders: string[] | undefined;
7
+ allowCredentials: boolean | undefined;
8
+ maxAge: wellKnownDuration | undefined;
9
+ };
10
+ type wellKnownDuration = string;
11
+ export {};
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/gen/servora/transport/http/cors/v1/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAC;CACvC,CAAC;AAMF,KAAK,iBAAiB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Code generated by protoc-gen-typescript-http. DO NOT EDIT.
2
+ /* eslint-disable camelcase */
3
+ // @ts-nocheck
4
+ export {};
5
+ // @@protoc_insertion_point(typescript-http-eof)
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/gen/servora/transport/http/cors/v1/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,8BAA8B;AAC9B,cAAc;;AAmBd,gDAAgD"}
@@ -0,0 +1,3 @@
1
+ export * from "./client/index.js";
2
+ export * from "./query.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./client/index.js";
2
+ export * from "./query.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}
package/dist/query.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare function makeFilter(fields?: null | Record<string, unknown>): str
37
37
  * makeOrderBy()
38
38
  * // → '["-created_at"]'
39
39
  */
40
+ export declare const DEFAULT_ORDER_BY: string[];
40
41
  export declare function makeOrderBy(fields?: null | string[]): string | undefined;
41
42
  /**
42
43
  * 生成 Proto FieldMask 字符串,用于 UpdateRequest.update_mask。
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,MAAM,GAAG,SAAS,CAKpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAIxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAGvD"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACtC,MAAM,GAAG,SAAS,CAKpB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,UAAkB,CAAC;AAEhD,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAIxE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAGvD"}
package/dist/query.js CHANGED
@@ -10,7 +10,7 @@
10
10
  */
11
11
  /** 过滤掉 null、undefined、空字符串的字段 */
12
12
  function omitEmpty(obj) {
13
- return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== null && v !== undefined && v !== ''));
13
+ return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== null && v !== undefined && v !== ""));
14
14
  }
15
15
  /**
16
16
  * 将过滤条件序列化为 Kratos ListRequest.filter 字符串。
@@ -48,11 +48,13 @@ export function makeFilter(fields) {
48
48
  * makeOrderBy()
49
49
  * // → '["-created_at"]'
50
50
  */
51
+ export const DEFAULT_ORDER_BY = ["-created_at"];
51
52
  export function makeOrderBy(fields) {
52
- const resolved = fields ?? ['-created_at'];
53
- if (resolved.length === 0)
53
+ if (fields == null)
54
+ return undefined;
55
+ if (fields.length === 0)
54
56
  return undefined;
55
- return JSON.stringify(resolved);
57
+ return JSON.stringify(fields);
56
58
  }
57
59
  /**
58
60
  * 生成 Proto FieldMask 字符串,用于 UpdateRequest.update_mask。
@@ -69,7 +71,7 @@ export function makeOrderBy(fields) {
69
71
  * // → 'name,avatar,id' (id 不重复出现)
70
72
  */
71
73
  export function makeUpdateMask(fields) {
72
- const without = fields.filter((f) => f !== 'id');
73
- return [...without, 'id'].join(',');
74
+ const unique = [...new Set(fields.filter((f) => f !== "id"))];
75
+ return [...unique, "id"].join(",");
74
76
  }
75
77
  //# sourceMappingURL=query.js.map
package/dist/query.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iCAAiC;AACjC,SAAS,SAAS,CAAC,GAA4B;IAC7C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CACxB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,CACrD,CACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CACxB,MAAuC;IAEvC,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,SAAS,CAAA;IACpC,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;IACjC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACvD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,MAAwB;IAClD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,CAAA;IAC1C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;IAChD,OAAO,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACrC,CAAC"}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iCAAiC;AACjC,SAAS,SAAS,CAAC,GAA4B;IAC7C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CACxB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,CACrD,CACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CACxB,MAAuC;IAEvC,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACrC,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACxD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,aAAa,CAAC,CAAC;AAEhD,MAAM,UAAU,WAAW,CAAC,MAAwB;IAClD,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACrC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,40 @@
1
1
  {
2
2
  "name": "@servora/proto-utils",
3
- "version": "0.0.2",
4
- "description": "Proto/Kratos API 查询工具:filter 序列化、order_by 编码、FieldMask 生成",
3
+ "version": "0.1.1",
4
+ "description": "Servora Proto 工具:CRUD 查询、FieldMask、HTTP client、Kratos 错误解析",
5
5
  "type": "module",
6
6
  "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ },
7
11
  "./query": {
8
12
  "types": "./dist/query.d.ts",
9
13
  "import": "./dist/query.js"
14
+ },
15
+ "./client": {
16
+ "types": "./dist/client/index.d.ts",
17
+ "import": "./dist/client/index.js"
18
+ },
19
+ "./client/request": {
20
+ "types": "./dist/client/request.d.ts",
21
+ "import": "./dist/client/request.js"
22
+ },
23
+ "./client/errors": {
24
+ "types": "./dist/client/errors.d.ts",
25
+ "import": "./dist/client/errors.js"
26
+ },
27
+ "./proto/*": {
28
+ "types": "./dist/gen/*/index.d.ts",
29
+ "import": "./dist/gen/*/index.js"
30
+ },
31
+ "./request": {
32
+ "types": "./dist/client/request.d.ts",
33
+ "import": "./dist/client/request.js"
34
+ },
35
+ "./errors": {
36
+ "types": "./dist/client/errors.d.ts",
37
+ "import": "./dist/client/errors.js"
10
38
  }
11
39
  },
12
40
  "files": [
@@ -22,15 +50,18 @@
22
50
  },
23
51
  "repository": {
24
52
  "type": "git",
25
- "url": "git+https://github.com/Servora-Kit/servora-web.git",
26
- "directory": "packages/proto-utils"
53
+ "url": "git+https://github.com/Servora-Kit/servora.git",
54
+ "directory": "web/packages/proto-utils"
27
55
  },
28
- "homepage": "https://github.com/Servora-Kit/servora-web/tree/main/packages/proto-utils",
56
+ "homepage": "https://github.com/Servora-Kit/servora/tree/main/web/packages/proto-utils",
29
57
  "bugs": {
30
- "url": "https://github.com/Servora-Kit/servora-web/issues"
58
+ "url": "https://github.com/Servora-Kit/servora/issues"
31
59
  },
32
60
  "license": "MIT",
33
61
  "sideEffects": false,
62
+ "dependencies": {
63
+ "ofetch": "^1.5.1"
64
+ },
34
65
  "devDependencies": {
35
66
  "typescript": "^5.7.2"
36
67
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Kratos 错误解析工具
3
+ *
4
+ * Kratos 统一错误格式:{ code, reason, message, metadata? }
5
+ * 所有使用 protoc-gen-go-errors 生成的服务均输出此格式。
6
+ */
7
+ import type { ApiError } from "./request.js";
8
+
9
+ export interface KratosErrorBody {
10
+ code: number;
11
+ reason: string;
12
+ message: string;
13
+ metadata?: Record<string, string>;
14
+ }
15
+
16
+ /**
17
+ * 从 ApiError 中提取 Kratos 结构化错误体。
18
+ * 非 HTTP 错误、或响应体不符合格式时返回 null。
19
+ */
20
+ export function parseKratosError(err: ApiError): KratosErrorBody | null {
21
+ if (err.kind !== "http" || !err.responseBody) return null;
22
+ const body = err.responseBody as Record<string, unknown>;
23
+ if (
24
+ typeof body.code !== "number" ||
25
+ typeof body.reason !== "string" ||
26
+ typeof body.message !== "string"
27
+ )
28
+ return null;
29
+ return body as unknown as KratosErrorBody;
30
+ }
31
+
32
+ /**
33
+ * 判断 ApiError 是否为指定的 Kratos reason。
34
+ *
35
+ * @example
36
+ * if (isKratosReason(err, 'EMAIL_NOT_VERIFIED')) { ... }
37
+ */
38
+ export function isKratosReason(err: ApiError, reason: string): boolean {
39
+ return parseKratosError(err)?.reason === reason;
40
+ }
41
+
42
+ /**
43
+ * 提取用户可读的错误消息,含 network / timeout 降级处理。
44
+ *
45
+ * @param fallback 当无法提取有效消息时的兜底文案,默认 '操作失败'
46
+ */
47
+ export function kratosMessage(err: ApiError, fallback = "操作失败"): string {
48
+ if (err.kind === "network") return "网络连接失败,请检查网络设置";
49
+ if (err.kind === "timeout") return "请求超时,请稍后重试";
50
+ return (
51
+ parseKratosError(err)?.message ??
52
+ (err.httpStatus ? `请求失败(HTTP ${err.httpStatus})` : fallback)
53
+ );
54
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./errors.js";
2
+ export * from "./request.js";