@alepha/protobuf 0.7.5 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,124 +1,136 @@
1
- 'use strict';
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
2
22
 
3
- var core = require('@alepha/core');
4
- var protobufjs = require('protobufjs');
23
+ //#endregion
24
+ const __alepha_core = __toESM(require("@alepha/core"));
25
+ const protobufjs = __toESM(require("protobufjs"));
5
26
 
6
- class ProtobufProvider {
7
- alepha = core.$inject(core.Alepha);
8
- schemas = /* @__PURE__ */ new Map();
9
- protobuf = protobufjs;
10
- /**
11
- * Encode an object to a Uint8Array.
12
- *
13
- * @param schema - TypeBox schema used to generate the Protobuf schema.
14
- * @param data - Object to encode. Can be any object or string.
15
- */
16
- encode(schema, data) {
17
- return this.parse(schema).encode(this.alepha.parse(schema, data)).finish();
18
- }
19
- /**
20
- * Decode a Uint8Array to an object.
21
- *
22
- * @param schema
23
- * @param data
24
- */
25
- decode(schema, data) {
26
- return this.alepha.parse(schema, this.parse(schema).decode(data));
27
- }
28
- /**
29
- * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
30
- *
31
- * @param schema
32
- * @param typeName
33
- */
34
- parse(schema, typeName = "root.Target") {
35
- const exists = this.schemas.get(schema);
36
- if (exists) return exists;
37
- const pbSchema = typeof schema === "string" ? schema : this.createProtobufSchema(schema);
38
- const result = this.protobuf.parse(pbSchema);
39
- const type = result.root.lookupType(typeName);
40
- this.schemas.set(schema, type);
41
- return type;
42
- }
43
- /**
44
- * Convert a TypeBox schema to a Protobuf schema as a string.
45
- *
46
- * @param schema
47
- * @param options
48
- */
49
- createProtobufSchema(schema, options = {}) {
50
- const { rootName = "root", mainMessageName = "Target" } = options;
51
- const context = {
52
- proto: `package ${rootName};
53
- syntax = "proto3";
54
-
55
- `,
56
- fieldIndex: 1
57
- };
58
- if (core.TypeGuard.IsObject(schema)) {
59
- const proto = this.parseObject(schema, mainMessageName, context);
60
- context.proto += proto;
61
- }
62
- return context.proto;
63
- }
64
- /**
65
- * Parse an object schema to a Protobuf message.
66
- *
67
- * @param obj
68
- * @param parentName
69
- * @param context
70
- * @protected
71
- */
72
- parseObject(obj, parentName, context) {
73
- if (!core.TypeGuard.IsObject(obj)) {
74
- return "";
75
- }
76
- const fields = [];
77
- for (const [key, value] of Object.entries(obj.properties)) {
78
- if (core.TypeGuard.IsArray(value)) {
79
- if (core.TypeGuard.IsObject(value.items)) {
80
- const subMessageName = value.items.title ?? `${parentName}_${key}`;
81
- context.proto += this.parseObject(value.items, subMessageName, {
82
- ...context,
83
- fieldIndex: 1
84
- });
85
- fields.push(
86
- ` repeated ${subMessageName} ${key} = ${context.fieldIndex++};`
87
- );
88
- continue;
89
- }
90
- const itemType = this.convertType(value.items);
91
- fields.push(` repeated ${itemType} ${key} = ${context.fieldIndex++};`);
92
- continue;
93
- }
94
- if (core.TypeGuard.IsObject(value)) {
95
- const subMessageName = `${parentName}_${key}`;
96
- context.proto += this.parseObject(value, subMessageName, context);
97
- fields.push(` ${subMessageName} ${key} = ${context.fieldIndex++};`);
98
- continue;
99
- }
100
- fields.push(
101
- ` ${this.convertType(value)} ${key} = ${context.fieldIndex++};`
102
- );
103
- }
104
- return `message ${parentName} {
105
- ${fields.join("\n")}
106
- }
107
- `;
108
- }
109
- /**
110
- * Convert a primitive TypeBox schema type to a Protobuf spec type.
111
- *
112
- * @param schema
113
- * @protected
114
- */
115
- convertType(schema) {
116
- if (core.TypeGuard.IsInteger(schema)) return "int32";
117
- if (core.TypeGuard.IsNumber(schema)) return "double";
118
- if (core.TypeGuard.IsString(schema)) return "string";
119
- if (core.TypeGuard.IsBoolean(schema)) return "bool";
120
- throw new Error(`Unsupported type: ${JSON.stringify(schema)}`);
121
- }
122
- }
27
+ //#region src/providers/ProtobufProvider.ts
28
+ var ProtobufProvider = class {
29
+ alepha = (0, __alepha_core.$inject)(__alepha_core.Alepha);
30
+ schemas = new Map();
31
+ protobuf = protobufjs.default;
32
+ /**
33
+ * Encode an object to a Uint8Array.
34
+ *
35
+ * @param schema - TypeBox schema used to generate the Protobuf schema.
36
+ * @param data - Object to encode. Can be any object or string.
37
+ */
38
+ encode(schema, data) {
39
+ return this.parse(schema).encode(this.alepha.parse(schema, data)).finish();
40
+ }
41
+ /**
42
+ * Decode a Uint8Array to an object.
43
+ *
44
+ * @param schema
45
+ * @param data
46
+ */
47
+ decode(schema, data) {
48
+ return this.alepha.parse(schema, this.parse(schema).decode(data));
49
+ }
50
+ /**
51
+ * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
52
+ *
53
+ * @param schema
54
+ * @param typeName
55
+ */
56
+ parse(schema, typeName = "root.Target") {
57
+ const exists = this.schemas.get(schema);
58
+ if (exists) return exists;
59
+ const pbSchema = typeof schema === "string" ? schema : this.createProtobufSchema(schema);
60
+ const result = this.protobuf.parse(pbSchema);
61
+ const type = result.root.lookupType(typeName);
62
+ this.schemas.set(schema, type);
63
+ return type;
64
+ }
65
+ /**
66
+ * Convert a TypeBox schema to a Protobuf schema as a string.
67
+ *
68
+ * @param schema
69
+ * @param options
70
+ */
71
+ createProtobufSchema(schema, options = {}) {
72
+ const { rootName = "root", mainMessageName = "Target" } = options;
73
+ const context = {
74
+ proto: `package ${rootName};\nsyntax = "proto3";\n\n`,
75
+ fieldIndex: 1
76
+ };
77
+ if (__alepha_core.TypeGuard.IsObject(schema)) {
78
+ const proto = this.parseObject(schema, mainMessageName, context);
79
+ context.proto += proto;
80
+ }
81
+ return context.proto;
82
+ }
83
+ /**
84
+ * Parse an object schema to a Protobuf message.
85
+ *
86
+ * @param obj
87
+ * @param parentName
88
+ * @param context
89
+ * @protected
90
+ */
91
+ parseObject(obj, parentName, context) {
92
+ if (!__alepha_core.TypeGuard.IsObject(obj)) return "";
93
+ const fields = [];
94
+ for (const [key, value] of Object.entries(obj.properties)) {
95
+ if (__alepha_core.TypeGuard.IsArray(value)) {
96
+ if (__alepha_core.TypeGuard.IsObject(value.items)) {
97
+ const subMessageName = value.items.title ?? `${parentName}_${key}`;
98
+ context.proto += this.parseObject(value.items, subMessageName, {
99
+ ...context,
100
+ fieldIndex: 1
101
+ });
102
+ fields.push(` repeated ${subMessageName} ${key} = ${context.fieldIndex++};`);
103
+ continue;
104
+ }
105
+ const itemType = this.convertType(value.items);
106
+ fields.push(` repeated ${itemType} ${key} = ${context.fieldIndex++};`);
107
+ continue;
108
+ }
109
+ if (__alepha_core.TypeGuard.IsObject(value)) {
110
+ const subMessageName = `${parentName}_${key}`;
111
+ context.proto += this.parseObject(value, subMessageName, context);
112
+ fields.push(` ${subMessageName} ${key} = ${context.fieldIndex++};`);
113
+ continue;
114
+ }
115
+ fields.push(` ${this.convertType(value)} ${key} = ${context.fieldIndex++};`);
116
+ }
117
+ return `message ${parentName} {\n${fields.join("\n")}\n}\n`;
118
+ }
119
+ /**
120
+ * Convert a primitive TypeBox schema type to a Protobuf spec type.
121
+ *
122
+ * @param schema
123
+ * @protected
124
+ */
125
+ convertType(schema) {
126
+ if (__alepha_core.TypeGuard.IsInteger(schema)) return "int32";
127
+ if (__alepha_core.TypeGuard.IsNumber(schema)) return "double";
128
+ if (__alepha_core.TypeGuard.IsString(schema)) return "string";
129
+ if (__alepha_core.TypeGuard.IsBoolean(schema)) return "bool";
130
+ throw new Error(`Unsupported type: ${JSON.stringify(schema)}`);
131
+ }
132
+ };
123
133
 
134
+ //#endregion
124
135
  exports.ProtobufProvider = ProtobufProvider;
136
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["Alepha","schema: TObject","data: any","schema: T","data: Uint8Array","schema: ProtobufSchema | TObject","schema: TSchema","options: CreateProtobufSchemaOptions","obj: TSchema","parentName: string","context: { proto: string; fieldIndex: number }","fields: string[]"],"sources":["../src/providers/ProtobufProvider.ts"],"sourcesContent":["import type { Static, TObject, TSchema } from \"@alepha/core\";\nimport { $inject, Alepha, TypeGuard } from \"@alepha/core\";\nimport type { Type } from \"protobufjs\";\nimport protobufjs from \"protobufjs\";\n\nexport class ProtobufProvider {\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly schemas = new Map<TObject | string, Type>();\n\tprotected readonly protobuf = protobufjs;\n\n\t/**\n\t * Encode an object to a Uint8Array.\n\t *\n\t * @param schema - TypeBox schema used to generate the Protobuf schema.\n\t * @param data - Object to encode. Can be any object or string.\n\t */\n\tpublic encode(schema: TObject, data: any): Uint8Array {\n\t\treturn this.parse(schema).encode(this.alepha.parse(schema, data)).finish();\n\t}\n\n\t/**\n\t * Decode a Uint8Array to an object.\n\t *\n\t * @param schema\n\t * @param data\n\t */\n\tpublic decode<T extends TObject>(schema: T, data: Uint8Array): Static<T> {\n\t\treturn this.alepha.parse(schema, this.parse(schema).decode(data));\n\t}\n\n\t/**\n\t * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.\n\t *\n\t * @param schema\n\t * @param typeName\n\t */\n\tpublic parse(\n\t\tschema: ProtobufSchema | TObject,\n\t\ttypeName = \"root.Target\",\n\t): Type {\n\t\tconst exists = this.schemas.get(schema);\n\t\tif (exists) return exists;\n\n\t\tconst pbSchema =\n\t\t\ttypeof schema === \"string\" ? schema : this.createProtobufSchema(schema);\n\t\tconst result = this.protobuf.parse(pbSchema);\n\t\tconst type = result.root.lookupType(typeName);\n\t\tthis.schemas.set(schema, type);\n\t\treturn type;\n\t}\n\n\t/**\n\t * Convert a TypeBox schema to a Protobuf schema as a string.\n\t *\n\t * @param schema\n\t * @param options\n\t */\n\tpublic createProtobufSchema(\n\t\tschema: TSchema,\n\t\toptions: CreateProtobufSchemaOptions = {},\n\t): string {\n\t\tconst { rootName = \"root\", mainMessageName = \"Target\" } = options;\n\t\tconst context = {\n\t\t\tproto: `package ${rootName};\\nsyntax = \"proto3\";\\n\\n`,\n\t\t\tfieldIndex: 1,\n\t\t};\n\n\t\tif (TypeGuard.IsObject(schema)) {\n\t\t\tconst proto = this.parseObject(schema, mainMessageName, context);\n\t\t\tcontext.proto += proto;\n\t\t}\n\n\t\treturn context.proto;\n\t}\n\n\t/**\n\t * Parse an object schema to a Protobuf message.\n\t *\n\t * @param obj\n\t * @param parentName\n\t * @param context\n\t * @protected\n\t */\n\tprotected parseObject(\n\t\tobj: TSchema,\n\t\tparentName: string,\n\t\tcontext: { proto: string; fieldIndex: number },\n\t): string {\n\t\tif (!TypeGuard.IsObject(obj)) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tconst fields: string[] = [];\n\n\t\tfor (const [key, value] of Object.entries(obj.properties)) {\n\t\t\tif (TypeGuard.IsArray(value)) {\n\t\t\t\tif (TypeGuard.IsObject(value.items)) {\n\t\t\t\t\tconst subMessageName = value.items.title ?? `${parentName}_${key}`;\n\t\t\t\t\tcontext.proto += this.parseObject(value.items, subMessageName, {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tfieldIndex: 1,\n\t\t\t\t\t});\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\t` repeated ${subMessageName} ${key} = ${context.fieldIndex++};`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst itemType = this.convertType(value.items);\n\t\t\t\tfields.push(` repeated ${itemType} ${key} = ${context.fieldIndex++};`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (TypeGuard.IsObject(value)) {\n\t\t\t\tconst subMessageName = `${parentName}_${key}`;\n\t\t\t\tcontext.proto += this.parseObject(value, subMessageName, context);\n\t\t\t\tfields.push(` ${subMessageName} ${key} = ${context.fieldIndex++};`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfields.push(\n\t\t\t\t` ${this.convertType(value)} ${key} = ${context.fieldIndex++};`,\n\t\t\t);\n\t\t}\n\n\t\treturn `message ${parentName} {\\n${fields.join(\"\\n\")}\\n}\\n`;\n\t}\n\n\t/**\n\t * Convert a primitive TypeBox schema type to a Protobuf spec type.\n\t *\n\t * @param schema\n\t * @protected\n\t */\n\tprotected convertType(schema: TSchema): string {\n\t\tif (TypeGuard.IsInteger(schema)) return \"int32\";\n\t\tif (TypeGuard.IsNumber(schema)) return \"double\";\n\t\tif (TypeGuard.IsString(schema)) return \"string\";\n\t\tif (TypeGuard.IsBoolean(schema)) return \"bool\";\n\n\t\tthrow new Error(`Unsupported type: ${JSON.stringify(schema)}`);\n\t}\n}\n\nexport type ProtobufSchema = string;\n\nexport interface CreateProtobufSchemaOptions {\n\trootName?: string;\n\tmainMessageName?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAa,mBAAb,MAA8B;CAC7B,AAAmB,SAAS,2BAAQA,qBAAO;CAC3C,AAAmB,UAAU,IAAI;CACjC,AAAmB,WAAW;;;;;;;CAQ9B,AAAO,OAAOC,QAAiBC,MAAuB;AACrD,SAAO,KAAK,MAAM,OAAO,CAAC,OAAO,KAAK,OAAO,MAAM,QAAQ,KAAK,CAAC,CAAC,QAAQ;CAC1E;;;;;;;CAQD,AAAO,OAA0BC,QAAWC,MAA6B;AACxE,SAAO,KAAK,OAAO,MAAM,QAAQ,KAAK,MAAM,OAAO,CAAC,OAAO,KAAK,CAAC;CACjE;;;;;;;CAQD,AAAO,MACNC,QACA,WAAW,eACJ;EACP,MAAM,SAAS,KAAK,QAAQ,IAAI,OAAO;AACvC,MAAI,OAAQ,QAAO;EAEnB,MAAM,kBACE,WAAW,WAAW,SAAS,KAAK,qBAAqB,OAAO;EACxE,MAAM,SAAS,KAAK,SAAS,MAAM,SAAS;EAC5C,MAAM,OAAO,OAAO,KAAK,WAAW,SAAS;AAC7C,OAAK,QAAQ,IAAI,QAAQ,KAAK;AAC9B,SAAO;CACP;;;;;;;CAQD,AAAO,qBACNC,QACAC,UAAuC,CAAE,GAChC;EACT,MAAM,EAAE,WAAW,QAAQ,kBAAkB,UAAU,GAAG;EAC1D,MAAM,UAAU;GACf,QAAQ,UAAU,SAAS;GAC3B,YAAY;EACZ;AAED,MAAI,wBAAU,SAAS,OAAO,EAAE;GAC/B,MAAM,QAAQ,KAAK,YAAY,QAAQ,iBAAiB,QAAQ;AAChE,WAAQ,SAAS;EACjB;AAED,SAAO,QAAQ;CACf;;;;;;;;;CAUD,AAAU,YACTC,KACAC,YACAC,SACS;AACT,OAAK,wBAAU,SAAS,IAAI,CAC3B,QAAO;EAGR,MAAMC,SAAmB,CAAE;AAE3B,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,IAAI,WAAW,EAAE;AAC1D,OAAI,wBAAU,QAAQ,MAAM,EAAE;AAC7B,QAAI,wBAAU,SAAS,MAAM,MAAM,EAAE;KACpC,MAAM,iBAAiB,MAAM,MAAM,UAAU,EAAE,WAAW,GAAG,IAAI;AACjE,aAAQ,SAAS,KAAK,YAAY,MAAM,OAAO,gBAAgB;MAC9D,GAAG;MACH,YAAY;KACZ,EAAC;AACF,YAAO,MACL,aAAa,eAAe,GAAG,IAAI,KAAK,QAAQ,aAAa,GAC9D;AACD;IACA;IAED,MAAM,WAAW,KAAK,YAAY,MAAM,MAAM;AAC9C,WAAO,MAAM,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,aAAa,GAAG;AACvE;GACA;AAED,OAAI,wBAAU,SAAS,MAAM,EAAE;IAC9B,MAAM,kBAAkB,EAAE,WAAW,GAAG,IAAI;AAC5C,YAAQ,SAAS,KAAK,YAAY,OAAO,gBAAgB,QAAQ;AACjE,WAAO,MAAM,IAAI,eAAe,GAAG,IAAI,KAAK,QAAQ,aAAa,GAAG;AACpE;GACA;AAED,UAAO,MACL,IAAI,KAAK,YAAY,MAAM,CAAC,GAAG,IAAI,KAAK,QAAQ,aAAa,GAC9D;EACD;AAED,UAAQ,UAAU,WAAW,MAAM,OAAO,KAAK,KAAK,CAAC;CACrD;;;;;;;CAQD,AAAU,YAAYL,QAAyB;AAC9C,MAAI,wBAAU,UAAU,OAAO,CAAE,QAAO;AACxC,MAAI,wBAAU,SAAS,OAAO,CAAE,QAAO;AACvC,MAAI,wBAAU,SAAS,OAAO,CAAE,QAAO;AACvC,MAAI,wBAAU,UAAU,OAAO,CAAE,QAAO;AAExC,QAAM,IAAI,OAAO,oBAAoB,KAAK,UAAU,OAAO,CAAC;CAC5D;AACD"}
@@ -0,0 +1,65 @@
1
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
2
+ import { Alepha, Static, TObject, TSchema } from "@alepha/core";
3
+ import protobufjs, { Type } from "protobufjs";
4
+
5
+ //#region src/providers/ProtobufProvider.d.ts
6
+ declare class ProtobufProvider {
7
+ protected readonly alepha: Alepha;
8
+ protected readonly schemas: Map<string | TObject<_sinclair_typebox0.TProperties>, Type>;
9
+ protected readonly protobuf: typeof protobufjs;
10
+ /**
11
+ * Encode an object to a Uint8Array.
12
+ *
13
+ * @param schema - TypeBox schema used to generate the Protobuf schema.
14
+ * @param data - Object to encode. Can be any object or string.
15
+ */
16
+ encode(schema: TObject, data: any): Uint8Array;
17
+ /**
18
+ * Decode a Uint8Array to an object.
19
+ *
20
+ * @param schema
21
+ * @param data
22
+ */
23
+ decode<T extends TObject>(schema: T, data: Uint8Array): Static<T>;
24
+ /**
25
+ * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
26
+ *
27
+ * @param schema
28
+ * @param typeName
29
+ */
30
+ parse(schema: ProtobufSchema | TObject, typeName?: string): Type;
31
+ /**
32
+ * Convert a TypeBox schema to a Protobuf schema as a string.
33
+ *
34
+ * @param schema
35
+ * @param options
36
+ */
37
+ createProtobufSchema(schema: TSchema, options?: CreateProtobufSchemaOptions): string;
38
+ /**
39
+ * Parse an object schema to a Protobuf message.
40
+ *
41
+ * @param obj
42
+ * @param parentName
43
+ * @param context
44
+ * @protected
45
+ */
46
+ protected parseObject(obj: TSchema, parentName: string, context: {
47
+ proto: string;
48
+ fieldIndex: number;
49
+ }): string;
50
+ /**
51
+ * Convert a primitive TypeBox schema type to a Protobuf spec type.
52
+ *
53
+ * @param schema
54
+ * @protected
55
+ */
56
+ protected convertType(schema: TSchema): string;
57
+ }
58
+ type ProtobufSchema = string;
59
+ interface CreateProtobufSchemaOptions {
60
+ rootName?: string;
61
+ mainMessageName?: string;
62
+ }
63
+ //#endregion
64
+ export { CreateProtobufSchemaOptions, ProtobufProvider, ProtobufSchema };
65
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,103 +1,65 @@
1
- import { Alepha, TObject, Static, TSchema as TSchema$1 } from '@alepha/core';
2
- import protobufjs, { Type } from 'protobufjs';
3
-
4
- /** Symbol key applied to readonly types */
5
- declare const ReadonlyKind: unique symbol;
6
- /** Symbol key applied to optional types */
7
- declare const OptionalKind: unique symbol;
8
- /** Symbol key applied to types */
9
- declare const Hint: unique symbol;
10
- /** Symbol key applied to types */
11
- declare const Kind: unique symbol;
12
-
13
- type TPropertyKey = string | number;
14
- type TProperties = Record<TPropertyKey, TSchema>;
15
-
16
- interface SchemaOptions {
17
- $schema?: string;
18
- /** Id for this schema */
19
- $id?: string;
20
- /** Title of this schema */
21
- title?: string;
22
- /** Description of this schema */
23
- description?: string;
24
- /** Default value for this schema */
25
- default?: any;
26
- /** Example values matching this schema */
27
- examples?: any;
28
- /** Optional annotation for readOnly */
29
- readOnly?: boolean;
30
- /** Optional annotation for writeOnly */
31
- writeOnly?: boolean;
32
- [prop: string]: any;
33
- }
34
- interface TKind {
35
- [Kind]: string;
36
- }
37
- interface TSchema extends TKind, SchemaOptions {
38
- [ReadonlyKind]?: string;
39
- [OptionalKind]?: string;
40
- [Hint]?: string;
41
- params: unknown[];
42
- static: unknown;
43
- }
1
+ import { Alepha, Static, TObject, TSchema } from "@alepha/core";
2
+ import protobufjs, { Type } from "protobufjs";
3
+ import * as _sinclair_typebox0 from "@sinclair/typebox";
44
4
 
5
+ //#region src/providers/ProtobufProvider.d.ts
45
6
  declare class ProtobufProvider {
46
- protected readonly alepha: Alepha;
47
- protected readonly schemas: Map<string | TObject<TProperties>, Type>;
48
- protected readonly protobuf: typeof protobufjs;
49
- /**
50
- * Encode an object to a Uint8Array.
51
- *
52
- * @param schema - TypeBox schema used to generate the Protobuf schema.
53
- * @param data - Object to encode. Can be any object or string.
54
- */
55
- encode(schema: TObject, data: any): Uint8Array;
56
- /**
57
- * Decode a Uint8Array to an object.
58
- *
59
- * @param schema
60
- * @param data
61
- */
62
- decode<T extends TObject>(schema: T, data: Uint8Array): Static<T>;
63
- /**
64
- * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
65
- *
66
- * @param schema
67
- * @param typeName
68
- */
69
- parse(schema: ProtobufSchema | TObject, typeName?: string): Type;
70
- /**
71
- * Convert a TypeBox schema to a Protobuf schema as a string.
72
- *
73
- * @param schema
74
- * @param options
75
- */
76
- createProtobufSchema(schema: TSchema$1, options?: CreateProtobufSchemaOptions): string;
77
- /**
78
- * Parse an object schema to a Protobuf message.
79
- *
80
- * @param obj
81
- * @param parentName
82
- * @param context
83
- * @protected
84
- */
85
- protected parseObject(obj: TSchema$1, parentName: string, context: {
86
- proto: string;
87
- fieldIndex: number;
88
- }): string;
89
- /**
90
- * Convert a primitive TypeBox schema type to a Protobuf spec type.
91
- *
92
- * @param schema
93
- * @protected
94
- */
95
- protected convertType(schema: TSchema$1): string;
7
+ protected readonly alepha: Alepha;
8
+ protected readonly schemas: Map<string | TObject<_sinclair_typebox0.TProperties>, Type>;
9
+ protected readonly protobuf: typeof protobufjs;
10
+ /**
11
+ * Encode an object to a Uint8Array.
12
+ *
13
+ * @param schema - TypeBox schema used to generate the Protobuf schema.
14
+ * @param data - Object to encode. Can be any object or string.
15
+ */
16
+ encode(schema: TObject, data: any): Uint8Array;
17
+ /**
18
+ * Decode a Uint8Array to an object.
19
+ *
20
+ * @param schema
21
+ * @param data
22
+ */
23
+ decode<T extends TObject>(schema: T, data: Uint8Array): Static<T>;
24
+ /**
25
+ * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
26
+ *
27
+ * @param schema
28
+ * @param typeName
29
+ */
30
+ parse(schema: ProtobufSchema | TObject, typeName?: string): Type;
31
+ /**
32
+ * Convert a TypeBox schema to a Protobuf schema as a string.
33
+ *
34
+ * @param schema
35
+ * @param options
36
+ */
37
+ createProtobufSchema(schema: TSchema, options?: CreateProtobufSchemaOptions): string;
38
+ /**
39
+ * Parse an object schema to a Protobuf message.
40
+ *
41
+ * @param obj
42
+ * @param parentName
43
+ * @param context
44
+ * @protected
45
+ */
46
+ protected parseObject(obj: TSchema, parentName: string, context: {
47
+ proto: string;
48
+ fieldIndex: number;
49
+ }): string;
50
+ /**
51
+ * Convert a primitive TypeBox schema type to a Protobuf spec type.
52
+ *
53
+ * @param schema
54
+ * @protected
55
+ */
56
+ protected convertType(schema: TSchema): string;
96
57
  }
97
58
  type ProtobufSchema = string;
98
59
  interface CreateProtobufSchemaOptions {
99
- rootName?: string;
100
- mainMessageName?: string;
60
+ rootName?: string;
61
+ mainMessageName?: string;
101
62
  }
102
-
103
- export { type CreateProtobufSchemaOptions, ProtobufProvider, type ProtobufSchema };
63
+ //#endregion
64
+ export { CreateProtobufSchemaOptions, ProtobufProvider, ProtobufSchema };
65
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,122 +1,113 @@
1
- import { $inject, Alepha, TypeGuard } from '@alepha/core';
2
- import protobufjs from 'protobufjs';
1
+ import { $inject, Alepha, TypeGuard } from "@alepha/core";
2
+ import protobufjs from "protobufjs";
3
3
 
4
- class ProtobufProvider {
5
- alepha = $inject(Alepha);
6
- schemas = /* @__PURE__ */ new Map();
7
- protobuf = protobufjs;
8
- /**
9
- * Encode an object to a Uint8Array.
10
- *
11
- * @param schema - TypeBox schema used to generate the Protobuf schema.
12
- * @param data - Object to encode. Can be any object or string.
13
- */
14
- encode(schema, data) {
15
- return this.parse(schema).encode(this.alepha.parse(schema, data)).finish();
16
- }
17
- /**
18
- * Decode a Uint8Array to an object.
19
- *
20
- * @param schema
21
- * @param data
22
- */
23
- decode(schema, data) {
24
- return this.alepha.parse(schema, this.parse(schema).decode(data));
25
- }
26
- /**
27
- * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
28
- *
29
- * @param schema
30
- * @param typeName
31
- */
32
- parse(schema, typeName = "root.Target") {
33
- const exists = this.schemas.get(schema);
34
- if (exists) return exists;
35
- const pbSchema = typeof schema === "string" ? schema : this.createProtobufSchema(schema);
36
- const result = this.protobuf.parse(pbSchema);
37
- const type = result.root.lookupType(typeName);
38
- this.schemas.set(schema, type);
39
- return type;
40
- }
41
- /**
42
- * Convert a TypeBox schema to a Protobuf schema as a string.
43
- *
44
- * @param schema
45
- * @param options
46
- */
47
- createProtobufSchema(schema, options = {}) {
48
- const { rootName = "root", mainMessageName = "Target" } = options;
49
- const context = {
50
- proto: `package ${rootName};
51
- syntax = "proto3";
52
-
53
- `,
54
- fieldIndex: 1
55
- };
56
- if (TypeGuard.IsObject(schema)) {
57
- const proto = this.parseObject(schema, mainMessageName, context);
58
- context.proto += proto;
59
- }
60
- return context.proto;
61
- }
62
- /**
63
- * Parse an object schema to a Protobuf message.
64
- *
65
- * @param obj
66
- * @param parentName
67
- * @param context
68
- * @protected
69
- */
70
- parseObject(obj, parentName, context) {
71
- if (!TypeGuard.IsObject(obj)) {
72
- return "";
73
- }
74
- const fields = [];
75
- for (const [key, value] of Object.entries(obj.properties)) {
76
- if (TypeGuard.IsArray(value)) {
77
- if (TypeGuard.IsObject(value.items)) {
78
- const subMessageName = value.items.title ?? `${parentName}_${key}`;
79
- context.proto += this.parseObject(value.items, subMessageName, {
80
- ...context,
81
- fieldIndex: 1
82
- });
83
- fields.push(
84
- ` repeated ${subMessageName} ${key} = ${context.fieldIndex++};`
85
- );
86
- continue;
87
- }
88
- const itemType = this.convertType(value.items);
89
- fields.push(` repeated ${itemType} ${key} = ${context.fieldIndex++};`);
90
- continue;
91
- }
92
- if (TypeGuard.IsObject(value)) {
93
- const subMessageName = `${parentName}_${key}`;
94
- context.proto += this.parseObject(value, subMessageName, context);
95
- fields.push(` ${subMessageName} ${key} = ${context.fieldIndex++};`);
96
- continue;
97
- }
98
- fields.push(
99
- ` ${this.convertType(value)} ${key} = ${context.fieldIndex++};`
100
- );
101
- }
102
- return `message ${parentName} {
103
- ${fields.join("\n")}
104
- }
105
- `;
106
- }
107
- /**
108
- * Convert a primitive TypeBox schema type to a Protobuf spec type.
109
- *
110
- * @param schema
111
- * @protected
112
- */
113
- convertType(schema) {
114
- if (TypeGuard.IsInteger(schema)) return "int32";
115
- if (TypeGuard.IsNumber(schema)) return "double";
116
- if (TypeGuard.IsString(schema)) return "string";
117
- if (TypeGuard.IsBoolean(schema)) return "bool";
118
- throw new Error(`Unsupported type: ${JSON.stringify(schema)}`);
119
- }
120
- }
4
+ //#region src/providers/ProtobufProvider.ts
5
+ var ProtobufProvider = class {
6
+ alepha = $inject(Alepha);
7
+ schemas = new Map();
8
+ protobuf = protobufjs;
9
+ /**
10
+ * Encode an object to a Uint8Array.
11
+ *
12
+ * @param schema - TypeBox schema used to generate the Protobuf schema.
13
+ * @param data - Object to encode. Can be any object or string.
14
+ */
15
+ encode(schema, data) {
16
+ return this.parse(schema).encode(this.alepha.parse(schema, data)).finish();
17
+ }
18
+ /**
19
+ * Decode a Uint8Array to an object.
20
+ *
21
+ * @param schema
22
+ * @param data
23
+ */
24
+ decode(schema, data) {
25
+ return this.alepha.parse(schema, this.parse(schema).decode(data));
26
+ }
27
+ /**
28
+ * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.
29
+ *
30
+ * @param schema
31
+ * @param typeName
32
+ */
33
+ parse(schema, typeName = "root.Target") {
34
+ const exists = this.schemas.get(schema);
35
+ if (exists) return exists;
36
+ const pbSchema = typeof schema === "string" ? schema : this.createProtobufSchema(schema);
37
+ const result = this.protobuf.parse(pbSchema);
38
+ const type = result.root.lookupType(typeName);
39
+ this.schemas.set(schema, type);
40
+ return type;
41
+ }
42
+ /**
43
+ * Convert a TypeBox schema to a Protobuf schema as a string.
44
+ *
45
+ * @param schema
46
+ * @param options
47
+ */
48
+ createProtobufSchema(schema, options = {}) {
49
+ const { rootName = "root", mainMessageName = "Target" } = options;
50
+ const context = {
51
+ proto: `package ${rootName};\nsyntax = "proto3";\n\n`,
52
+ fieldIndex: 1
53
+ };
54
+ if (TypeGuard.IsObject(schema)) {
55
+ const proto = this.parseObject(schema, mainMessageName, context);
56
+ context.proto += proto;
57
+ }
58
+ return context.proto;
59
+ }
60
+ /**
61
+ * Parse an object schema to a Protobuf message.
62
+ *
63
+ * @param obj
64
+ * @param parentName
65
+ * @param context
66
+ * @protected
67
+ */
68
+ parseObject(obj, parentName, context) {
69
+ if (!TypeGuard.IsObject(obj)) return "";
70
+ const fields = [];
71
+ for (const [key, value] of Object.entries(obj.properties)) {
72
+ if (TypeGuard.IsArray(value)) {
73
+ if (TypeGuard.IsObject(value.items)) {
74
+ const subMessageName = value.items.title ?? `${parentName}_${key}`;
75
+ context.proto += this.parseObject(value.items, subMessageName, {
76
+ ...context,
77
+ fieldIndex: 1
78
+ });
79
+ fields.push(` repeated ${subMessageName} ${key} = ${context.fieldIndex++};`);
80
+ continue;
81
+ }
82
+ const itemType = this.convertType(value.items);
83
+ fields.push(` repeated ${itemType} ${key} = ${context.fieldIndex++};`);
84
+ continue;
85
+ }
86
+ if (TypeGuard.IsObject(value)) {
87
+ const subMessageName = `${parentName}_${key}`;
88
+ context.proto += this.parseObject(value, subMessageName, context);
89
+ fields.push(` ${subMessageName} ${key} = ${context.fieldIndex++};`);
90
+ continue;
91
+ }
92
+ fields.push(` ${this.convertType(value)} ${key} = ${context.fieldIndex++};`);
93
+ }
94
+ return `message ${parentName} {\n${fields.join("\n")}\n}\n`;
95
+ }
96
+ /**
97
+ * Convert a primitive TypeBox schema type to a Protobuf spec type.
98
+ *
99
+ * @param schema
100
+ * @protected
101
+ */
102
+ convertType(schema) {
103
+ if (TypeGuard.IsInteger(schema)) return "int32";
104
+ if (TypeGuard.IsNumber(schema)) return "double";
105
+ if (TypeGuard.IsString(schema)) return "string";
106
+ if (TypeGuard.IsBoolean(schema)) return "bool";
107
+ throw new Error(`Unsupported type: ${JSON.stringify(schema)}`);
108
+ }
109
+ };
121
110
 
111
+ //#endregion
122
112
  export { ProtobufProvider };
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["schema: TObject","data: any","schema: T","data: Uint8Array","schema: ProtobufSchema | TObject","schema: TSchema","options: CreateProtobufSchemaOptions","obj: TSchema","parentName: string","context: { proto: string; fieldIndex: number }","fields: string[]"],"sources":["../src/providers/ProtobufProvider.ts"],"sourcesContent":["import type { Static, TObject, TSchema } from \"@alepha/core\";\nimport { $inject, Alepha, TypeGuard } from \"@alepha/core\";\nimport type { Type } from \"protobufjs\";\nimport protobufjs from \"protobufjs\";\n\nexport class ProtobufProvider {\n\tprotected readonly alepha = $inject(Alepha);\n\tprotected readonly schemas = new Map<TObject | string, Type>();\n\tprotected readonly protobuf = protobufjs;\n\n\t/**\n\t * Encode an object to a Uint8Array.\n\t *\n\t * @param schema - TypeBox schema used to generate the Protobuf schema.\n\t * @param data - Object to encode. Can be any object or string.\n\t */\n\tpublic encode(schema: TObject, data: any): Uint8Array {\n\t\treturn this.parse(schema).encode(this.alepha.parse(schema, data)).finish();\n\t}\n\n\t/**\n\t * Decode a Uint8Array to an object.\n\t *\n\t * @param schema\n\t * @param data\n\t */\n\tpublic decode<T extends TObject>(schema: T, data: Uint8Array): Static<T> {\n\t\treturn this.alepha.parse(schema, this.parse(schema).decode(data));\n\t}\n\n\t/**\n\t * Parse a TypeBox schema to a Protobuf Type schema ready for encoding/decoding.\n\t *\n\t * @param schema\n\t * @param typeName\n\t */\n\tpublic parse(\n\t\tschema: ProtobufSchema | TObject,\n\t\ttypeName = \"root.Target\",\n\t): Type {\n\t\tconst exists = this.schemas.get(schema);\n\t\tif (exists) return exists;\n\n\t\tconst pbSchema =\n\t\t\ttypeof schema === \"string\" ? schema : this.createProtobufSchema(schema);\n\t\tconst result = this.protobuf.parse(pbSchema);\n\t\tconst type = result.root.lookupType(typeName);\n\t\tthis.schemas.set(schema, type);\n\t\treturn type;\n\t}\n\n\t/**\n\t * Convert a TypeBox schema to a Protobuf schema as a string.\n\t *\n\t * @param schema\n\t * @param options\n\t */\n\tpublic createProtobufSchema(\n\t\tschema: TSchema,\n\t\toptions: CreateProtobufSchemaOptions = {},\n\t): string {\n\t\tconst { rootName = \"root\", mainMessageName = \"Target\" } = options;\n\t\tconst context = {\n\t\t\tproto: `package ${rootName};\\nsyntax = \"proto3\";\\n\\n`,\n\t\t\tfieldIndex: 1,\n\t\t};\n\n\t\tif (TypeGuard.IsObject(schema)) {\n\t\t\tconst proto = this.parseObject(schema, mainMessageName, context);\n\t\t\tcontext.proto += proto;\n\t\t}\n\n\t\treturn context.proto;\n\t}\n\n\t/**\n\t * Parse an object schema to a Protobuf message.\n\t *\n\t * @param obj\n\t * @param parentName\n\t * @param context\n\t * @protected\n\t */\n\tprotected parseObject(\n\t\tobj: TSchema,\n\t\tparentName: string,\n\t\tcontext: { proto: string; fieldIndex: number },\n\t): string {\n\t\tif (!TypeGuard.IsObject(obj)) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tconst fields: string[] = [];\n\n\t\tfor (const [key, value] of Object.entries(obj.properties)) {\n\t\t\tif (TypeGuard.IsArray(value)) {\n\t\t\t\tif (TypeGuard.IsObject(value.items)) {\n\t\t\t\t\tconst subMessageName = value.items.title ?? `${parentName}_${key}`;\n\t\t\t\t\tcontext.proto += this.parseObject(value.items, subMessageName, {\n\t\t\t\t\t\t...context,\n\t\t\t\t\t\tfieldIndex: 1,\n\t\t\t\t\t});\n\t\t\t\t\tfields.push(\n\t\t\t\t\t\t` repeated ${subMessageName} ${key} = ${context.fieldIndex++};`,\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst itemType = this.convertType(value.items);\n\t\t\t\tfields.push(` repeated ${itemType} ${key} = ${context.fieldIndex++};`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (TypeGuard.IsObject(value)) {\n\t\t\t\tconst subMessageName = `${parentName}_${key}`;\n\t\t\t\tcontext.proto += this.parseObject(value, subMessageName, context);\n\t\t\t\tfields.push(` ${subMessageName} ${key} = ${context.fieldIndex++};`);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfields.push(\n\t\t\t\t` ${this.convertType(value)} ${key} = ${context.fieldIndex++};`,\n\t\t\t);\n\t\t}\n\n\t\treturn `message ${parentName} {\\n${fields.join(\"\\n\")}\\n}\\n`;\n\t}\n\n\t/**\n\t * Convert a primitive TypeBox schema type to a Protobuf spec type.\n\t *\n\t * @param schema\n\t * @protected\n\t */\n\tprotected convertType(schema: TSchema): string {\n\t\tif (TypeGuard.IsInteger(schema)) return \"int32\";\n\t\tif (TypeGuard.IsNumber(schema)) return \"double\";\n\t\tif (TypeGuard.IsString(schema)) return \"string\";\n\t\tif (TypeGuard.IsBoolean(schema)) return \"bool\";\n\n\t\tthrow new Error(`Unsupported type: ${JSON.stringify(schema)}`);\n\t}\n}\n\nexport type ProtobufSchema = string;\n\nexport interface CreateProtobufSchemaOptions {\n\trootName?: string;\n\tmainMessageName?: string;\n}\n"],"mappings":";;;;AAKA,IAAa,mBAAb,MAA8B;CAC7B,AAAmB,SAAS,QAAQ,OAAO;CAC3C,AAAmB,UAAU,IAAI;CACjC,AAAmB,WAAW;;;;;;;CAQ9B,AAAO,OAAOA,QAAiBC,MAAuB;AACrD,SAAO,KAAK,MAAM,OAAO,CAAC,OAAO,KAAK,OAAO,MAAM,QAAQ,KAAK,CAAC,CAAC,QAAQ;CAC1E;;;;;;;CAQD,AAAO,OAA0BC,QAAWC,MAA6B;AACxE,SAAO,KAAK,OAAO,MAAM,QAAQ,KAAK,MAAM,OAAO,CAAC,OAAO,KAAK,CAAC;CACjE;;;;;;;CAQD,AAAO,MACNC,QACA,WAAW,eACJ;EACP,MAAM,SAAS,KAAK,QAAQ,IAAI,OAAO;AACvC,MAAI,OAAQ,QAAO;EAEnB,MAAM,kBACE,WAAW,WAAW,SAAS,KAAK,qBAAqB,OAAO;EACxE,MAAM,SAAS,KAAK,SAAS,MAAM,SAAS;EAC5C,MAAM,OAAO,OAAO,KAAK,WAAW,SAAS;AAC7C,OAAK,QAAQ,IAAI,QAAQ,KAAK;AAC9B,SAAO;CACP;;;;;;;CAQD,AAAO,qBACNC,QACAC,UAAuC,CAAE,GAChC;EACT,MAAM,EAAE,WAAW,QAAQ,kBAAkB,UAAU,GAAG;EAC1D,MAAM,UAAU;GACf,QAAQ,UAAU,SAAS;GAC3B,YAAY;EACZ;AAED,MAAI,UAAU,SAAS,OAAO,EAAE;GAC/B,MAAM,QAAQ,KAAK,YAAY,QAAQ,iBAAiB,QAAQ;AAChE,WAAQ,SAAS;EACjB;AAED,SAAO,QAAQ;CACf;;;;;;;;;CAUD,AAAU,YACTC,KACAC,YACAC,SACS;AACT,OAAK,UAAU,SAAS,IAAI,CAC3B,QAAO;EAGR,MAAMC,SAAmB,CAAE;AAE3B,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,IAAI,WAAW,EAAE;AAC1D,OAAI,UAAU,QAAQ,MAAM,EAAE;AAC7B,QAAI,UAAU,SAAS,MAAM,MAAM,EAAE;KACpC,MAAM,iBAAiB,MAAM,MAAM,UAAU,EAAE,WAAW,GAAG,IAAI;AACjE,aAAQ,SAAS,KAAK,YAAY,MAAM,OAAO,gBAAgB;MAC9D,GAAG;MACH,YAAY;KACZ,EAAC;AACF,YAAO,MACL,aAAa,eAAe,GAAG,IAAI,KAAK,QAAQ,aAAa,GAC9D;AACD;IACA;IAED,MAAM,WAAW,KAAK,YAAY,MAAM,MAAM;AAC9C,WAAO,MAAM,aAAa,SAAS,GAAG,IAAI,KAAK,QAAQ,aAAa,GAAG;AACvE;GACA;AAED,OAAI,UAAU,SAAS,MAAM,EAAE;IAC9B,MAAM,kBAAkB,EAAE,WAAW,GAAG,IAAI;AAC5C,YAAQ,SAAS,KAAK,YAAY,OAAO,gBAAgB,QAAQ;AACjE,WAAO,MAAM,IAAI,eAAe,GAAG,IAAI,KAAK,QAAQ,aAAa,GAAG;AACpE;GACA;AAED,UAAO,MACL,IAAI,KAAK,YAAY,MAAM,CAAC,GAAG,IAAI,KAAK,QAAQ,aAAa,GAC9D;EACD;AAED,UAAQ,UAAU,WAAW,MAAM,OAAO,KAAK,KAAK,CAAC;CACrD;;;;;;;CAQD,AAAU,YAAYL,QAAyB;AAC9C,MAAI,UAAU,UAAU,OAAO,CAAE,QAAO;AACxC,MAAI,UAAU,SAAS,OAAO,CAAE,QAAO;AACvC,MAAI,UAAU,SAAS,OAAO,CAAE,QAAO;AACvC,MAAI,UAAU,UAAU,OAAO,CAAE,QAAO;AAExC,QAAM,IAAI,OAAO,oBAAoB,KAAK,UAAU,OAAO,CAAC;CAC5D;AACD"}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@alepha/protobuf",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
+ "engines": {
6
+ "node": ">=22.0.0"
7
+ },
5
8
  "license": "MIT",
6
9
  "main": "./dist/index.js",
7
10
  "types": "./dist/index.d.ts",
@@ -10,16 +13,16 @@
10
13
  "src"
11
14
  ],
12
15
  "dependencies": {
13
- "@alepha/core": "0.7.5",
16
+ "@alepha/core": "0.7.7",
14
17
  "protobufjs": "^7.5.3"
15
18
  },
16
19
  "devDependencies": {
17
- "pkgroll": "^2.13.1",
20
+ "tsdown": "^0.12.9",
18
21
  "vitest": "^3.2.4"
19
22
  },
20
23
  "scripts": {
21
24
  "test": "vitest run",
22
- "build": "pkgroll --clean-dist"
25
+ "build": "tsdown -c ../../tsdown.config.ts"
23
26
  },
24
27
  "homepage": "https://github.com/feunard/alepha",
25
28
  "repository": {