@akashnetwork/chain-sdk 1.0.0-alpha.22 → 1.0.0-alpha.24
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/README.md +42 -4
- package/dist/cjs/index.shared.cjs +1 -0
- package/dist/cjs/index.shared.cjs.map +2 -2
- package/dist/cjs/sdl/SDL/SDL.cjs +12 -12
- package/dist/cjs/sdl/SDL/SDL.cjs.map +2 -2
- package/dist/cjs/sdl/SDL/SdlValidationError.cjs.map +2 -2
- package/dist/cjs/sdl/index.cjs +6 -1
- package/dist/cjs/sdl/index.cjs.map +2 -2
- package/dist/cjs/sdl/manifest/generateManifest.cjs +241 -0
- package/dist/cjs/sdl/manifest/generateManifest.cjs.map +7 -0
- package/dist/cjs/sdl/manifest/generateManifestVersion.cjs +84 -0
- package/dist/cjs/sdl/manifest/generateManifestVersion.cjs.map +7 -0
- package/dist/cjs/sdl/manifest/manifestUtils.cjs +138 -0
- package/dist/cjs/sdl/manifest/manifestUtils.cjs.map +7 -0
- package/dist/cjs/sdl/types.cjs.map +1 -1
- package/dist/cjs/sdl/{SDL/utils.cjs.map → utils.cjs.map} +1 -1
- package/dist/cjs/sdl/{SDL/validateSDL → validateSDL}/validateSDL.cjs +20 -13
- package/dist/cjs/sdl/validateSDL/validateSDL.cjs.map +7 -0
- package/dist/cjs/sdl/{SDL/validateSDL → validateSDL}/validateSDLInput.cjs +3 -3
- package/dist/cjs/sdl/validateSDL/validateSDLInput.cjs.map +7 -0
- package/dist/cjs/utils/yaml.cjs +44 -0
- package/dist/cjs/utils/yaml.cjs.map +7 -0
- package/dist/esm/chunk-2XL6OX6E.js +1 -0
- package/dist/esm/chunk-2XL6OX6E.js.map +7 -0
- package/dist/esm/{chunk-K3L3J5XB.js → chunk-4D3QNKFB.js} +3 -3
- package/dist/esm/{chunk-DUCGLLTN.js → chunk-5DCYIWCG.js} +100 -100
- package/dist/esm/{chunk-DUCGLLTN.js.map → chunk-5DCYIWCG.js.map} +4 -4
- package/dist/esm/{chunk-BGBAJIKV.js → chunk-5YECXI3P.js} +2 -2
- package/dist/esm/{chunk-MEXNRJE4.js → chunk-BYQF33C6.js} +2 -2
- package/dist/esm/{chunk-R5DUC7IU.js → chunk-C7UQYVYH.js} +2 -2
- package/dist/esm/{chunk-726NIMPF.js → chunk-JISXXX24.js} +2 -2
- package/dist/esm/{chunk-6OEI5BYK.js → chunk-RIIYZIXM.js} +479 -65
- package/dist/esm/chunk-RIIYZIXM.js.map +7 -0
- package/dist/esm/{chunk-EYW7M3KV.js → chunk-SA4SEZ6F.js} +2 -2
- package/dist/esm/{chunk-ST2QQ72E.js → chunk-VRE72ZD5.js} +2 -2
- package/dist/esm/{chunk-A5CS5ZKQ.js → chunk-XFCN5LRY.js} +2 -2
- package/dist/esm/chunk-Z5KZUB7X.js +364 -0
- package/dist/esm/chunk-Z5KZUB7X.js.map +7 -0
- package/dist/esm/generated/protos/index.akash.v1.js +6 -6
- package/dist/esm/generated/protos/index.akash.v1beta4.js +14 -349
- package/dist/esm/generated/protos/index.akash.v1beta4.js.map +4 -4
- package/dist/esm/generated/protos/index.akash.v1beta5.js +5 -5
- package/dist/esm/generated/protos/index.provider.akash.v1.js +3 -3
- package/dist/esm/generated/protos/index.provider.akash.v2beta3.js +3 -2
- package/dist/esm/index.js +30 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.web.js +29 -3
- package/dist/esm/index.web.js.map +1 -1
- package/dist/esm/{query_akash-XTPHUGJZ.js → query_akash-4CTLBKZR.js} +4 -4
- package/dist/esm/{query_akash-IXSQT2VJ.js → query_akash-DJ7LTLRE.js} +5 -5
- package/dist/esm/{service_akash-YMJ4ZYYX.js → service_akash-AZFAYT7H.js} +4 -4
- package/dist/esm/{service_akash-2EBLHFIP.js → service_akash-VMU3LNBA.js} +4 -4
- package/dist/esm/{service_akash-AYYJKBHS.js → service_akash-WRGOVR7I.js} +4 -4
- package/dist/sdl-schema.yaml +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/index.shared.d.ts +1 -0
- package/dist/types/sdl/SDL/SDL.d.ts +2 -0
- package/dist/types/sdl/SDL/SdlValidationError.d.ts +3 -0
- package/dist/types/sdl/index.d.ts +5 -2
- package/dist/types/sdl/manifest/generateManifest.d.ts +18 -0
- package/dist/types/sdl/manifest/generateManifestVersion.d.ts +3 -0
- package/dist/types/sdl/manifest/manifestUtils.d.ts +27 -0
- package/dist/types/sdl/types.d.ts +53 -1
- package/dist/types/sdl/{SDL/validateSDL → validateSDL}/validateSDL.d.ts +2 -2
- package/dist/types/utils/yaml.d.ts +38 -0
- package/package.json +1 -1
- package/dist/cjs/sdl/SDL/validateSDL/validateSDL.cjs.map +0 -7
- package/dist/cjs/sdl/SDL/validateSDL/validateSDLInput.cjs.map +0 -7
- package/dist/esm/chunk-6OEI5BYK.js.map +0 -7
- /package/dist/cjs/sdl/{SDL/utils.cjs → utils.cjs} +0 -0
- /package/dist/esm/{chunk-K3L3J5XB.js.map → chunk-4D3QNKFB.js.map} +0 -0
- /package/dist/esm/{chunk-BGBAJIKV.js.map → chunk-5YECXI3P.js.map} +0 -0
- /package/dist/esm/{chunk-MEXNRJE4.js.map → chunk-BYQF33C6.js.map} +0 -0
- /package/dist/esm/{chunk-R5DUC7IU.js.map → chunk-C7UQYVYH.js.map} +0 -0
- /package/dist/esm/{chunk-726NIMPF.js.map → chunk-JISXXX24.js.map} +0 -0
- /package/dist/esm/{chunk-EYW7M3KV.js.map → chunk-SA4SEZ6F.js.map} +0 -0
- /package/dist/esm/{chunk-ST2QQ72E.js.map → chunk-VRE72ZD5.js.map} +0 -0
- /package/dist/esm/{chunk-A5CS5ZKQ.js.map → chunk-XFCN5LRY.js.map} +0 -0
- /package/dist/esm/{query_akash-XTPHUGJZ.js.map → query_akash-4CTLBKZR.js.map} +0 -0
- /package/dist/esm/{query_akash-IXSQT2VJ.js.map → query_akash-DJ7LTLRE.js.map} +0 -0
- /package/dist/esm/{service_akash-YMJ4ZYYX.js.map → service_akash-AZFAYT7H.js.map} +0 -0
- /package/dist/esm/{service_akash-2EBLHFIP.js.map → service_akash-VMU3LNBA.js.map} +0 -0
- /package/dist/esm/{service_akash-AYYJKBHS.js.map → service_akash-WRGOVR7I.js.map} +0 -0
- /package/dist/types/sdl/{SDL/utils.d.ts → utils.d.ts} +0 -0
- /package/dist/types/sdl/{SDL/validateSDL → validateSDL}/validateSDLInput.d.ts +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var generateManifest_exports = {};
|
|
20
|
+
__export(generateManifest_exports, {
|
|
21
|
+
generateManifest: () => generateManifest
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(generateManifest_exports);
|
|
24
|
+
var import_attribute = require("../../generated/protos/akash/base/attributes/v1/attribute.cjs");
|
|
25
|
+
var import_cpu = require("../../generated/protos/akash/base/resources/v1beta4/cpu.cjs");
|
|
26
|
+
var import_gpu = require("../../generated/protos/akash/base/resources/v1beta4/gpu.cjs");
|
|
27
|
+
var import_memory = require("../../generated/protos/akash/base/resources/v1beta4/memory.cjs");
|
|
28
|
+
var import_resources = require("../../generated/protos/akash/base/resources/v1beta4/resources.cjs");
|
|
29
|
+
var import_storage = require("../../generated/protos/akash/base/resources/v1beta4/storage.cjs");
|
|
30
|
+
var import_groupspec = require("../../generated/protos/akash/deployment/v1beta4/groupspec.cjs");
|
|
31
|
+
var import_resourceunit = require("../../generated/protos/akash/deployment/v1beta4/resourceunit.cjs");
|
|
32
|
+
var import_group = require("../../generated/protos/akash/manifest/v2beta3/group.cjs");
|
|
33
|
+
var import_service = require("../../generated/protos/akash/manifest/v2beta3/service.cjs");
|
|
34
|
+
var import_serviceexpose = require("../../generated/protos/akash/manifest/v2beta3/serviceexpose.cjs");
|
|
35
|
+
var import_config = require("../../network/config.cjs");
|
|
36
|
+
var import_utils = require("../utils.cjs");
|
|
37
|
+
var import_validateSDL = require("../validateSDL/validateSDL.cjs");
|
|
38
|
+
var import_manifestUtils = require("./manifestUtils.cjs");
|
|
39
|
+
function generateManifest(sdl, networkId = import_config.MAINNET_ID) {
|
|
40
|
+
const errors = (0, import_validateSDL.validateSDL)(sdl, networkId);
|
|
41
|
+
if (errors) return { ok: false, value: errors };
|
|
42
|
+
const endpointSequenceNumbers = (0, import_manifestUtils.computeEndpointSequenceNumbers)(sdl.services);
|
|
43
|
+
const groupsMap = /* @__PURE__ */ new Map();
|
|
44
|
+
const resourceIds = /* @__PURE__ */ new Map();
|
|
45
|
+
const deploymentsByPlacement = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const [svcName, placements] of Object.entries(sdl.deployment)) {
|
|
47
|
+
for (const [placementName, deployment] of Object.entries(placements)) {
|
|
48
|
+
let list = deploymentsByPlacement.get(placementName);
|
|
49
|
+
if (!list) {
|
|
50
|
+
list = [];
|
|
51
|
+
deploymentsByPlacement.set(placementName, list);
|
|
52
|
+
}
|
|
53
|
+
list.push([svcName, deployment]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const list of deploymentsByPlacement.values()) {
|
|
57
|
+
list.sort(([a], [b]) => a.localeCompare(b));
|
|
58
|
+
}
|
|
59
|
+
const services = Object.entries(sdl.services).sort(([a], [b]) => a.localeCompare(b));
|
|
60
|
+
for (const [svcName, service] of services) {
|
|
61
|
+
for (const [placementName, svcdepl] of Object.entries(sdl.deployment[svcName])) {
|
|
62
|
+
const compute = sdl.profiles.compute[svcdepl.profile];
|
|
63
|
+
const infra = sdl.profiles.placement[placementName];
|
|
64
|
+
const pricing = infra.pricing[svcdepl.profile];
|
|
65
|
+
const price = {
|
|
66
|
+
denom: pricing.denom,
|
|
67
|
+
amount: pricing.amount?.toString()
|
|
68
|
+
};
|
|
69
|
+
let group = groupsMap.get(placementName);
|
|
70
|
+
if (!group) {
|
|
71
|
+
group = {
|
|
72
|
+
dgroup: import_groupspec.GroupSpec.fromPartial({
|
|
73
|
+
name: placementName,
|
|
74
|
+
resources: [],
|
|
75
|
+
requirements: import_attribute.PlacementRequirements.fromPartial({
|
|
76
|
+
attributes: (0, import_manifestUtils.buildResourceAttributes)(infra.attributes) ?? [],
|
|
77
|
+
signedBy: import_attribute.SignedBy.fromPartial({
|
|
78
|
+
allOf: infra.signedBy?.allOf,
|
|
79
|
+
anyOf: infra.signedBy?.anyOf
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
boundComputes: {}
|
|
84
|
+
};
|
|
85
|
+
groupsMap.set(placementName, group);
|
|
86
|
+
}
|
|
87
|
+
const profileKey = `${placementName}:${svcdepl.profile}`;
|
|
88
|
+
const location = group.boundComputes[svcdepl.profile];
|
|
89
|
+
if (location === void 0) {
|
|
90
|
+
const resId = group.dgroup.resources.length > 0 ? group.dgroup.resources.length + 1 : 1;
|
|
91
|
+
resourceIds.set(profileKey, resId);
|
|
92
|
+
const resources = buildResources(resId, compute, service, endpointSequenceNumbers);
|
|
93
|
+
group.dgroup.resources.push(
|
|
94
|
+
import_resourceunit.ResourceUnit.fromPartial({
|
|
95
|
+
resource: resources,
|
|
96
|
+
count: svcdepl.count,
|
|
97
|
+
price
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
group.boundComputes[svcdepl.profile] = group.dgroup.resources.length - 1;
|
|
101
|
+
} else {
|
|
102
|
+
if (!resourceIds.has(profileKey)) {
|
|
103
|
+
resourceIds.set(profileKey, group.dgroup.resources[location].resource.id);
|
|
104
|
+
}
|
|
105
|
+
group.dgroup.resources[location].count += svcdepl.count;
|
|
106
|
+
group.dgroup.resources[location].resource.endpoints.push(
|
|
107
|
+
...(0, import_manifestUtils.buildServiceEndpoints)(service, endpointSequenceNumbers)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const group of groupsMap.values()) {
|
|
113
|
+
for (const resourceUnit of group.dgroup.resources) {
|
|
114
|
+
resourceUnit.resource.endpoints.sort(
|
|
115
|
+
(a, b) => a.kind - b.kind || a.sequenceNumber - b.sequenceNumber
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const sortedGroupNames = [...groupsMap.keys()].sort();
|
|
120
|
+
let groups;
|
|
121
|
+
let groupSpecs;
|
|
122
|
+
const manifest = {
|
|
123
|
+
get groups() {
|
|
124
|
+
groups ?? (groups = sortedGroupNames.map((placementName) => {
|
|
125
|
+
const deployments = deploymentsByPlacement.get(placementName);
|
|
126
|
+
return import_group.Group.fromPartial({
|
|
127
|
+
name: placementName,
|
|
128
|
+
services: deployments.map(([svcName]) => {
|
|
129
|
+
const service = sdl.services[svcName];
|
|
130
|
+
const deployment = sdl.deployment[svcName][placementName];
|
|
131
|
+
const compute = sdl.profiles.compute[deployment.profile];
|
|
132
|
+
const resourceId = resourceIds.get(`${placementName}:${deployment.profile}`) || 1;
|
|
133
|
+
return buildManifestService(
|
|
134
|
+
resourceId,
|
|
135
|
+
svcName,
|
|
136
|
+
service,
|
|
137
|
+
compute,
|
|
138
|
+
deployment.count,
|
|
139
|
+
endpointSequenceNumbers
|
|
140
|
+
);
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}));
|
|
144
|
+
return groups;
|
|
145
|
+
},
|
|
146
|
+
get groupSpecs() {
|
|
147
|
+
groupSpecs ?? (groupSpecs = sortedGroupNames.map((name) => groupsMap.get(name).dgroup));
|
|
148
|
+
return groupSpecs;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
return { ok: true, value: manifest };
|
|
152
|
+
}
|
|
153
|
+
function buildResources(id, compute, service, endpointSequenceNumbers) {
|
|
154
|
+
const res = compute.resources;
|
|
155
|
+
const cpuAttributes = (0, import_manifestUtils.buildResourceAttributes)(res.cpu.attributes);
|
|
156
|
+
const gpuAttributes = res.gpu?.attributes ? (0, import_manifestUtils.transformGpuAttributes)(res.gpu.attributes) : [];
|
|
157
|
+
return import_resources.Resources.fromPartial({
|
|
158
|
+
id,
|
|
159
|
+
cpu: import_cpu.CPU.fromPartial({
|
|
160
|
+
units: { val: (0, import_manifestUtils.encodeResourceValue)((0, import_manifestUtils.parseCpuUnits)(res.cpu)) },
|
|
161
|
+
attributes: cpuAttributes
|
|
162
|
+
}),
|
|
163
|
+
memory: import_memory.Memory.fromPartial({
|
|
164
|
+
quantity: { val: (0, import_manifestUtils.encodeResourceValue)((0, import_manifestUtils.parseMemoryBytes)(res.memory)) }
|
|
165
|
+
}),
|
|
166
|
+
storage: (0, import_utils.castArray)(res.storage).map(
|
|
167
|
+
(s) => import_storage.Storage.fromPartial({
|
|
168
|
+
name: s.name || "default",
|
|
169
|
+
quantity: { val: (0, import_manifestUtils.encodeResourceValue)((0, import_manifestUtils.parseStorageBytes)(s.size)) },
|
|
170
|
+
attributes: (0, import_manifestUtils.buildStorageAttributes)(s.attributes)
|
|
171
|
+
})
|
|
172
|
+
),
|
|
173
|
+
gpu: import_gpu.GPU.fromPartial({
|
|
174
|
+
units: { val: (0, import_manifestUtils.encodeResourceValue)((0, import_manifestUtils.parseGpuUnits)(res.gpu)) },
|
|
175
|
+
attributes: gpuAttributes
|
|
176
|
+
}),
|
|
177
|
+
endpoints: (0, import_manifestUtils.buildServiceEndpoints)(service, endpointSequenceNumbers)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function buildManifestService(resourceId, name, service, compute, count, endpointSequenceNumbers) {
|
|
181
|
+
const credentials = service.credentials ? import_service.ImageCredentials.fromPartial({
|
|
182
|
+
host: service.credentials.host,
|
|
183
|
+
email: service.credentials.email || "",
|
|
184
|
+
username: service.credentials.username,
|
|
185
|
+
password: service.credentials.password
|
|
186
|
+
}) : void 0;
|
|
187
|
+
const params = buildParams(service);
|
|
188
|
+
return import_service.Service.fromPartial({
|
|
189
|
+
name,
|
|
190
|
+
image: service.image,
|
|
191
|
+
command: service.command || [],
|
|
192
|
+
args: service.args || [],
|
|
193
|
+
env: service.env || [],
|
|
194
|
+
resources: buildResources(resourceId, compute, service, endpointSequenceNumbers),
|
|
195
|
+
count,
|
|
196
|
+
expose: buildManifestExpose(service, endpointSequenceNumbers),
|
|
197
|
+
params,
|
|
198
|
+
credentials
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function buildParams(service) {
|
|
202
|
+
if (!service.params) return void 0;
|
|
203
|
+
const storageEntries = Object.entries(service.params.storage ?? {});
|
|
204
|
+
const result = import_service.ServiceParams.fromPartial({
|
|
205
|
+
storage: storageEntries.map(
|
|
206
|
+
([name, config]) => import_service.StorageParams.fromPartial({
|
|
207
|
+
name,
|
|
208
|
+
mount: config.mount || "",
|
|
209
|
+
readOnly: config.readOnly || false
|
|
210
|
+
})
|
|
211
|
+
)
|
|
212
|
+
});
|
|
213
|
+
if (service.params.permissions) {
|
|
214
|
+
result.permissions = service.params.permissions;
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
217
|
+
}
|
|
218
|
+
function buildManifestExpose(service, endpointSequenceNumbers) {
|
|
219
|
+
return (service.expose ?? []).flatMap(
|
|
220
|
+
(expose) => (expose.to ?? []).map(
|
|
221
|
+
(to) => import_serviceexpose.ServiceExpose.fromPartial({
|
|
222
|
+
port: expose.port,
|
|
223
|
+
externalPort: expose.as,
|
|
224
|
+
proto: (0, import_manifestUtils.parseServiceProto)(expose.proto),
|
|
225
|
+
service: to.service || "",
|
|
226
|
+
global: to.global || false,
|
|
227
|
+
hosts: expose.accept || [],
|
|
228
|
+
httpOptions: (0, import_manifestUtils.buildHttpOptions)(expose.http_options),
|
|
229
|
+
ip: to.ip || "",
|
|
230
|
+
endpointSequenceNumber: endpointSequenceNumbers[to.ip]
|
|
231
|
+
})
|
|
232
|
+
)
|
|
233
|
+
).sort((a, b) => {
|
|
234
|
+
if (a.service !== b.service) return a.service.localeCompare(b.service);
|
|
235
|
+
if (a.port !== b.port) return a.port - b.port;
|
|
236
|
+
if (a.proto !== b.proto) return a.proto.localeCompare(b.proto);
|
|
237
|
+
if (a.global !== b.global) return a.global ? -1 : 1;
|
|
238
|
+
return 0;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=generateManifest.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/manifest/generateManifest.ts"],
|
|
4
|
+
"sourcesContent": ["import { PlacementRequirements, SignedBy } from \"../../generated/protos/akash/base/attributes/v1/attribute.ts\";\nimport { CPU } from \"../../generated/protos/akash/base/resources/v1beta4/cpu.ts\";\nimport { GPU } from \"../../generated/protos/akash/base/resources/v1beta4/gpu.ts\";\nimport { Memory } from \"../../generated/protos/akash/base/resources/v1beta4/memory.ts\";\nimport { Resources } from \"../../generated/protos/akash/base/resources/v1beta4/resources.ts\";\nimport { Storage } from \"../../generated/protos/akash/base/resources/v1beta4/storage.ts\";\nimport { GroupSpec } from \"../../generated/protos/akash/deployment/v1beta4/groupspec.ts\";\nimport { ResourceUnit } from \"../../generated/protos/akash/deployment/v1beta4/resourceunit.ts\";\nimport { Group } from \"../../generated/protos/akash/manifest/v2beta3/group.ts\";\nimport { ImageCredentials, Service, ServiceParams, StorageParams } from \"../../generated/protos/akash/manifest/v2beta3/service.ts\";\nimport { ServiceExpose } from \"../../generated/protos/akash/manifest/v2beta3/serviceexpose.ts\";\nimport { MAINNET_ID } from \"../../network/config.ts\";\nimport type { NetworkId } from \"../../network/types.ts\";\nimport type { ValidationError } from \"../../utils/jsonSchemaValidation.ts\";\nimport { castArray } from \"../utils.ts\";\nimport type { SDLInput } from \"../validateSDL/validateSDL.ts\";\nimport { validateSDL } from \"../validateSDL/validateSDL.ts\";\nimport {\n buildHttpOptions,\n buildResourceAttributes,\n buildServiceEndpoints,\n buildStorageAttributes,\n computeEndpointSequenceNumbers,\n encodeResourceValue,\n parseCpuUnits,\n parseGpuUnits,\n parseMemoryBytes,\n parseServiceProto,\n parseStorageBytes,\n type SDLCompute,\n type SDLService,\n transformGpuAttributes,\n} from \"./manifestUtils.ts\";\n\nexport interface BuildResult {\n groups: Group[];\n groupSpecs: GroupSpec[];\n}\n\nexport type Manifest = BuildResult[\"groups\"];\nexport type GenerateManifestResult =\n | { ok?: false; value: ValidationError[] }\n | { ok: true; value: BuildResult };\nexport function generateManifest(sdl: SDLInput, networkId: NetworkId = MAINNET_ID): GenerateManifestResult {\n const errors = validateSDL(sdl, networkId);\n if (errors) return { ok: false, value: errors };\n\n const endpointSequenceNumbers = computeEndpointSequenceNumbers(sdl.services);\n const groupsMap = new Map<string, {\n dgroup: GroupSpec;\n boundComputes: Record<string, number>;\n }>();\n const resourceIds = new Map<string, number>();\n\n const deploymentsByPlacement = new Map<string, [string, { profile: string; count: number }][]>();\n for (const [svcName, placements] of Object.entries(sdl.deployment)) {\n for (const [placementName, deployment] of Object.entries(placements)) {\n let list = deploymentsByPlacement.get(placementName);\n if (!list) {\n list = [];\n deploymentsByPlacement.set(placementName, list);\n }\n list.push([svcName, deployment]);\n }\n }\n for (const list of deploymentsByPlacement.values()) {\n list.sort(([a], [b]) => a.localeCompare(b));\n }\n\n const services = Object.entries(sdl.services).sort(([a], [b]) => a.localeCompare(b));\n\n for (const [svcName, service] of services) {\n for (const [placementName, svcdepl] of Object.entries(sdl.deployment[svcName])) {\n const compute = sdl.profiles.compute[svcdepl.profile];\n const infra = sdl.profiles.placement[placementName];\n const pricing = infra.pricing[svcdepl.profile];\n const price = {\n denom: pricing.denom,\n amount: pricing.amount?.toString(),\n };\n\n let group = groupsMap.get(placementName);\n\n if (!group) {\n group = {\n dgroup: GroupSpec.fromPartial({\n name: placementName,\n resources: [],\n requirements: PlacementRequirements.fromPartial({\n attributes: buildResourceAttributes(infra.attributes) ?? [],\n signedBy: SignedBy.fromPartial({\n allOf: infra.signedBy?.allOf,\n anyOf: infra.signedBy?.anyOf,\n }),\n }),\n }),\n boundComputes: {},\n };\n\n groupsMap.set(placementName, group);\n }\n\n const profileKey = `${placementName}:${svcdepl.profile}`;\n const location = group.boundComputes[svcdepl.profile];\n\n if (location === undefined) {\n const resId = group.dgroup.resources.length > 0\n ? group.dgroup.resources.length + 1\n : 1;\n\n resourceIds.set(profileKey, resId);\n\n const resources = buildResources(resId, compute, service, endpointSequenceNumbers);\n\n group.dgroup.resources.push(\n ResourceUnit.fromPartial({\n resource: resources,\n count: svcdepl.count,\n price,\n }),\n );\n\n group.boundComputes[svcdepl.profile] = group.dgroup.resources.length - 1;\n } else {\n if (!resourceIds.has(profileKey)) {\n resourceIds.set(profileKey, group.dgroup.resources[location].resource!.id);\n }\n\n group.dgroup.resources[location].count += svcdepl.count;\n group.dgroup.resources[location].resource!.endpoints.push(\n ...buildServiceEndpoints(service, endpointSequenceNumbers),\n );\n }\n }\n }\n\n for (const group of groupsMap.values()) {\n for (const resourceUnit of group.dgroup.resources) {\n resourceUnit.resource!.endpoints.sort(\n (a, b) => a.kind - b.kind || a.sequenceNumber - b.sequenceNumber,\n );\n }\n }\n\n const sortedGroupNames = [...groupsMap.keys()].sort();\n let groups: Group[] | undefined;\n let groupSpecs: GroupSpec[] | undefined;\n\n const manifest = {\n get groups() {\n groups ??= sortedGroupNames.map((placementName) => {\n const deployments = deploymentsByPlacement.get(placementName)!;\n\n return Group.fromPartial({\n name: placementName,\n services: deployments.map(([svcName]) => {\n const service = sdl.services[svcName];\n const deployment = sdl.deployment[svcName][placementName];\n const compute = sdl.profiles.compute[deployment.profile];\n const resourceId = resourceIds.get(`${placementName}:${deployment.profile}`) || 1;\n\n return buildManifestService(\n resourceId,\n svcName,\n service,\n compute,\n deployment.count,\n endpointSequenceNumbers,\n );\n }),\n });\n });\n return groups;\n },\n get groupSpecs() {\n groupSpecs ??= sortedGroupNames.map((name) => groupsMap.get(name)!.dgroup);\n return groupSpecs;\n },\n };\n\n return { ok: true, value: manifest };\n}\n\nfunction buildResources(\n id: number,\n compute: SDLCompute,\n service: SDLService,\n endpointSequenceNumbers: Record<string, number>,\n): Resources {\n const res = compute.resources;\n const cpuAttributes = buildResourceAttributes(res.cpu.attributes);\n const gpuAttributes = res.gpu?.attributes ? transformGpuAttributes(res.gpu.attributes) : [];\n\n return Resources.fromPartial({\n id,\n cpu: CPU.fromPartial({\n units: { val: encodeResourceValue(parseCpuUnits(res.cpu)) },\n attributes: cpuAttributes,\n }),\n memory: Memory.fromPartial({\n quantity: { val: encodeResourceValue(parseMemoryBytes(res.memory)) },\n }),\n storage: castArray(res.storage).map((s) =>\n Storage.fromPartial({\n name: s.name || \"default\",\n quantity: { val: encodeResourceValue(parseStorageBytes(s.size)) },\n attributes: buildStorageAttributes(s.attributes),\n }),\n ),\n gpu: GPU.fromPartial({\n units: { val: encodeResourceValue(parseGpuUnits(res.gpu)) },\n attributes: gpuAttributes,\n }),\n endpoints: buildServiceEndpoints(service, endpointSequenceNumbers),\n });\n}\n\nfunction buildManifestService(\n resourceId: number,\n name: string,\n service: SDLService,\n compute: SDLCompute,\n count: number,\n endpointSequenceNumbers: Record<string, number>,\n): Service {\n const credentials = service.credentials\n ? ImageCredentials.fromPartial({\n host: service.credentials.host,\n email: service.credentials.email || \"\",\n username: service.credentials.username,\n password: service.credentials.password,\n })\n : undefined;\n\n const params = buildParams(service);\n\n return Service.fromPartial({\n name,\n image: service.image,\n command: service.command || [],\n args: service.args || [],\n env: service.env || [],\n resources: buildResources(resourceId, compute, service, endpointSequenceNumbers),\n count,\n expose: buildManifestExpose(service, endpointSequenceNumbers),\n params,\n credentials,\n });\n}\n\nfunction buildParams(service: SDLService): ServiceParams | undefined {\n if (!service.params) return undefined;\n\n const storageEntries = Object.entries(service.params.storage ?? {});\n const result = ServiceParams.fromPartial({\n storage: storageEntries.map(([name, config]) =>\n StorageParams.fromPartial({\n name,\n mount: config.mount || \"\",\n readOnly: config.readOnly || false,\n }),\n ),\n });\n\n // Permissions are not in the protobuf type but need to be preserved\n if (service.params.permissions) {\n (result as unknown as Record<string, unknown>).permissions = service.params.permissions;\n }\n\n return result;\n}\n\nfunction buildManifestExpose(\n service: SDLService,\n endpointSequenceNumbers: Record<string, number>,\n): ServiceExpose[] {\n return (service.expose ?? [])\n .flatMap((expose) =>\n (expose.to ?? []).map((to) =>\n ServiceExpose.fromPartial({\n port: expose.port,\n externalPort: expose.as,\n proto: parseServiceProto(expose.proto),\n service: to.service || \"\",\n global: to.global || false,\n hosts: expose.accept || [],\n httpOptions: buildHttpOptions(expose.http_options),\n ip: to.ip || \"\",\n endpointSequenceNumber: endpointSequenceNumbers[to.ip!],\n }),\n ),\n )\n .sort((a, b) => {\n if (a.service !== b.service) return a.service.localeCompare(b.service);\n if (a.port !== b.port) return a.port - b.port;\n if (a.proto !== b.proto) return a.proto.localeCompare(b.proto);\n if (a.global !== b.global) return a.global ? -1 : 1;\n return 0;\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAgD;AAChD,iBAAoB;AACpB,iBAAoB;AACpB,oBAAuB;AACvB,uBAA0B;AAC1B,qBAAwB;AACxB,uBAA0B;AAC1B,0BAA6B;AAC7B,mBAAsB;A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AE,YAAY,EAAE,QAAS,QAAO,EAAE,QAAQ,cAAc,EAAE,OAAO;AACrE,QAAI,EAAE,SAAS,EAAE,KAAM,QAAO,EAAE,OAAO,EAAE;AACzC,QAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,MAAM,cAAc,EAAE,KAAK;AAC7D,QAAI,EAAE,WAAW,EAAE,OAAQ,QAAO,EAAE,SAAS,KAAK;AAClD,WAAO;AAAA,EACT,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
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 __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var generateManifestVersion_exports = {};
|
|
30
|
+
__export(generateManifestVersion_exports, {
|
|
31
|
+
generateManifestVersion: () => generateManifestVersion,
|
|
32
|
+
manifestToSortedJSON: () => manifestToSortedJSON
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(generateManifestVersion_exports);
|
|
35
|
+
var import_json_stable_stringify = __toESM(require("json-stable-stringify"), 1);
|
|
36
|
+
const decoder = new TextDecoder();
|
|
37
|
+
const encoder = new TextEncoder();
|
|
38
|
+
const NULLABLE_MANIFEST_KEYS = /* @__PURE__ */ new Set(["command", "args", "env", "hosts"]);
|
|
39
|
+
const OMITTED_MANIFEST_KEYS = /* @__PURE__ */ new Set(["kind", "attributes"]);
|
|
40
|
+
async function generateManifestVersion(manifest) {
|
|
41
|
+
const jsonStr = manifestToSortedJSON(manifest);
|
|
42
|
+
const sortedBytes = encoder.encode(jsonStr);
|
|
43
|
+
const sum = await crypto.subtle.digest("SHA-256", sortedBytes);
|
|
44
|
+
return new Uint8Array(sum);
|
|
45
|
+
}
|
|
46
|
+
function manifestToSortedJSON(manifest) {
|
|
47
|
+
const json = (0, import_json_stable_stringify.default)(manifest, { replacer: manifestReplacer }) || "";
|
|
48
|
+
return escapeHtml(renameFields(json));
|
|
49
|
+
}
|
|
50
|
+
function manifestReplacer(key, value) {
|
|
51
|
+
if (value && value instanceof Uint8Array) {
|
|
52
|
+
return decoder.decode(value);
|
|
53
|
+
}
|
|
54
|
+
if (typeof key !== "string") {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
if (typeof this === "object" && this && Object.hasOwn(this, "command") && key === "credentials" && value == null) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (NULLABLE_MANIFEST_KEYS.has(key) && (Array.isArray(value) && value.length === 0 || value == null)) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (OMITTED_MANIFEST_KEYS.has(key) && (Array.isArray(value) && value.length === 0 || value === 0)) {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
const MANIFEST_VERSION_FIELD_MAPPING = { quantity: "size", sequenceNumber: "sequence_number" };
|
|
69
|
+
const MANIFEST_VERSION_FIELD_REGEX = new RegExp(`"(${Object.keys(MANIFEST_VERSION_FIELD_MAPPING).join("|")})":`, "g");
|
|
70
|
+
function renameFields(jsonStr) {
|
|
71
|
+
MANIFEST_VERSION_FIELD_REGEX.lastIndex = 0;
|
|
72
|
+
return jsonStr.replace(MANIFEST_VERSION_FIELD_REGEX, (_, field) => `"${MANIFEST_VERSION_FIELD_MAPPING[field]}":`);
|
|
73
|
+
}
|
|
74
|
+
const htmlEscapes = {
|
|
75
|
+
"<": "\\u003c",
|
|
76
|
+
">": "\\u003e",
|
|
77
|
+
"&": "\\u0026"
|
|
78
|
+
};
|
|
79
|
+
const HTML_SPECIAL_CHARS_REGEX = new RegExp(`[${Object.keys(htmlEscapes).join("")}]`, "g");
|
|
80
|
+
function escapeHtml(raw) {
|
|
81
|
+
HTML_SPECIAL_CHARS_REGEX.lastIndex = 0;
|
|
82
|
+
return raw.replace(HTML_SPECIAL_CHARS_REGEX, (ch) => htmlEscapes[ch]);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=generateManifestVersion.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/manifest/generateManifestVersion.ts"],
|
|
4
|
+
"sourcesContent": ["import { default as stableStringify } from \"json-stable-stringify\";\n\nimport type { Manifest } from \"./generateManifest.ts\";\n\nconst decoder = new TextDecoder();\nconst encoder = new TextEncoder();\nconst NULLABLE_MANIFEST_KEYS = new Set([\"command\", \"args\", \"env\", \"hosts\"]);\nconst OMITTED_MANIFEST_KEYS = new Set([\"kind\", \"attributes\"]);\n\nexport async function generateManifestVersion(manifest: Manifest): Promise<Uint8Array> {\n const jsonStr = manifestToSortedJSON(manifest);\n const sortedBytes = encoder.encode(jsonStr);\n const sum = await crypto.subtle.digest(\"SHA-256\", sortedBytes);\n return new Uint8Array(sum);\n}\n\nexport function manifestToSortedJSON(manifest: Manifest): string {\n const json = stableStringify(manifest, { replacer: manifestReplacer }) || \"\";\n return escapeHtml(renameFields(json));\n}\n\nfunction manifestReplacer(this: unknown, key: string | number, value: unknown): unknown {\n if (value && value instanceof Uint8Array) {\n return decoder.decode(value);\n }\n\n if (typeof key !== \"string\") {\n return value;\n }\n\n // only top-level \"credentials\" field can be null, credentials in params should be omitted\n if (typeof this === \"object\" && this && Object.hasOwn(this, \"command\") && key === \"credentials\" && value == null) {\n return null;\n }\n\n if (NULLABLE_MANIFEST_KEYS.has(key) && ((Array.isArray(value) && value.length === 0) || value == null)) {\n return null;\n }\n\n if (OMITTED_MANIFEST_KEYS.has(key) && ((Array.isArray(value) && value.length === 0) || value === 0)) {\n return undefined;\n }\n\n return value;\n}\n\nconst MANIFEST_VERSION_FIELD_MAPPING: Record<string, string> = { quantity: \"size\", sequenceNumber: \"sequence_number\" };\nconst MANIFEST_VERSION_FIELD_REGEX = new RegExp(`\"(${Object.keys(MANIFEST_VERSION_FIELD_MAPPING).join(\"|\")})\":`, \"g\");\nfunction renameFields(jsonStr: string): string {\n MANIFEST_VERSION_FIELD_REGEX.lastIndex = 0; // reset regex state\n return jsonStr.replace(MANIFEST_VERSION_FIELD_REGEX, (_, field) => `\"${MANIFEST_VERSION_FIELD_MAPPING[field]}\":`);\n}\n\nconst htmlEscapes: Record<string, string> = {\n \"<\": \"\\\\u003c\",\n \">\": \"\\\\u003e\",\n \"&\": \"\\\\u0026\",\n};\n\nconst HTML_SPECIAL_CHARS_REGEX = new RegExp(`[${Object.keys(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,MAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,KAAM,UAAU,IAAI;AACnG,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEA,MAAM,iCAAyD,EAAE,UAAU,QAAQ,gBAAgB,kBAAkB;AACrH,MAAM,+BAA+B,IAAI,OAAO,KAAK,OAAO,KAAK,8BAA8B,EAAE,KAAK,GAAG,CAAC,OAAO,GAAG;AACpH,SAAS,aAAa,SAAyB;AAC7C,+BAA6B,YAAY;AACzC,SAAO,QAAQ,QAAQ,8BAA8B,CAAC,GAAG,UAAU,IAAI,+BAA+B,KAAK,CAAC,IAAI;AAClH;AAEA,MAAM,cAAsC;AAAA,EAC1C,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AACP;AAEA,MAAM,2BAA2B,IAAI,OAAO,IAAI,OAAO,KAAK,WAAW,EAAE,KAAK,EAAE,CAAC,KAAK,GAAG;AACzF,SAAS,WAAW,KAAqB;AACvC,2BAAyB,YAAY;AACrC,SAAO,IAAI,QAAQ,0BAA0B,CAAC,OAAO,YAAY,EAAE,CAAC;AACtE;",
|
|
6
|
+
"names": ["stableStringify"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var manifestUtils_exports = {};
|
|
20
|
+
__export(manifestUtils_exports, {
|
|
21
|
+
buildHttpOptions: () => buildHttpOptions,
|
|
22
|
+
buildResourceAttributes: () => buildResourceAttributes,
|
|
23
|
+
buildServiceEndpoints: () => buildServiceEndpoints,
|
|
24
|
+
buildStorageAttributes: () => buildStorageAttributes,
|
|
25
|
+
computeEndpointSequenceNumbers: () => computeEndpointSequenceNumbers,
|
|
26
|
+
encodeResourceValue: () => encodeResourceValue,
|
|
27
|
+
isIngress: () => isIngress,
|
|
28
|
+
parseCpuUnits: () => parseCpuUnits,
|
|
29
|
+
parseGpuUnits: () => parseGpuUnits,
|
|
30
|
+
parseMemoryBytes: () => parseMemoryBytes,
|
|
31
|
+
parseServiceProto: () => parseServiceProto,
|
|
32
|
+
parseStorageBytes: () => parseStorageBytes,
|
|
33
|
+
transformGpuAttributes: () => transformGpuAttributes
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(manifestUtils_exports);
|
|
36
|
+
var import_index_akash_v1beta4 = require("../../generated/protos/index.akash.v1beta4.cjs");
|
|
37
|
+
var import_index_provider_akash_v2beta3 = require("../../generated/protos/index.provider.akash.v2beta3.cjs");
|
|
38
|
+
var import_sizes = require("../sizes.cjs");
|
|
39
|
+
const encoder = new TextEncoder();
|
|
40
|
+
function encodeResourceValue(value) {
|
|
41
|
+
return encoder.encode(value.toString());
|
|
42
|
+
}
|
|
43
|
+
function computeEndpointSequenceNumbers(services) {
|
|
44
|
+
const endpointNames = [];
|
|
45
|
+
for (const service of Object.values(services)) {
|
|
46
|
+
if (!service.expose) continue;
|
|
47
|
+
for (const expose of service.expose) {
|
|
48
|
+
if (!expose.to) continue;
|
|
49
|
+
for (const to of expose.to) {
|
|
50
|
+
if (to.global && to.ip && to.ip.length > 0) {
|
|
51
|
+
endpointNames.push(to.ip);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return endpointNames.sort().reduce((result, name, seqNumber) => {
|
|
57
|
+
result[name] = seqNumber + 1;
|
|
58
|
+
return result;
|
|
59
|
+
}, {});
|
|
60
|
+
}
|
|
61
|
+
function isIngress(proto, global, externalPort, port) {
|
|
62
|
+
const effectivePort = externalPort === 0 ? port : externalPort;
|
|
63
|
+
return global && proto === "TCP" && effectivePort === 80;
|
|
64
|
+
}
|
|
65
|
+
function transformGpuAttributes(attributes) {
|
|
66
|
+
const vendor = attributes.vendor;
|
|
67
|
+
if (!vendor) return [];
|
|
68
|
+
return Object.entries(vendor).flatMap(
|
|
69
|
+
([vendorName, models]) => models ? models.map((model) => {
|
|
70
|
+
let key = `vendor/${vendorName}/model/${model.model}`;
|
|
71
|
+
if (model.ram) key += `/ram/${model.ram}`;
|
|
72
|
+
if (model.interface) key += `/interface/${model.interface}`;
|
|
73
|
+
return { key, value: "true" };
|
|
74
|
+
}) : [{ key: `vendor/${vendorName}/model/*`, value: "true" }]
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function buildHttpOptions(httpOptions) {
|
|
78
|
+
return import_index_provider_akash_v2beta3.ServiceExposeHTTPOptions.fromPartial({
|
|
79
|
+
maxBodySize: httpOptions?.max_body_size ?? 1048576,
|
|
80
|
+
readTimeout: httpOptions?.read_timeout ?? 6e4,
|
|
81
|
+
sendTimeout: httpOptions?.send_timeout ?? 6e4,
|
|
82
|
+
nextTries: httpOptions?.next_tries ?? 3,
|
|
83
|
+
nextTimeout: httpOptions?.next_timeout ?? 0,
|
|
84
|
+
nextCases: httpOptions?.next_cases ?? ["error", "timeout"]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function buildStorageAttributes(attributes) {
|
|
88
|
+
if (!attributes) return [];
|
|
89
|
+
const pairs = Object.entries(attributes).map(([key, value]) => ({
|
|
90
|
+
key,
|
|
91
|
+
value: String(value)
|
|
92
|
+
}));
|
|
93
|
+
if (attributes.class === "ram" && !("persistent" in attributes)) {
|
|
94
|
+
pairs.push({ key: "persistent", value: "false" });
|
|
95
|
+
}
|
|
96
|
+
pairs.sort((a, b) => a.key.localeCompare(b.key));
|
|
97
|
+
return pairs;
|
|
98
|
+
}
|
|
99
|
+
function parseServiceProto(proto) {
|
|
100
|
+
return proto?.toUpperCase() || "TCP";
|
|
101
|
+
}
|
|
102
|
+
function buildServiceEndpoints(service, endpointSequenceNumbers) {
|
|
103
|
+
return (service.expose ?? []).flatMap(
|
|
104
|
+
(expose) => (expose.to ?? []).filter((to) => to.global).flatMap((to) => {
|
|
105
|
+
const externalPort = expose.as || 0;
|
|
106
|
+
const proto = parseServiceProto(expose.proto);
|
|
107
|
+
const kind = isIngress(proto, !!to.global, externalPort, expose.port) ? import_index_akash_v1beta4.Endpoint_Kind.SHARED_HTTP : import_index_akash_v1beta4.Endpoint_Kind.RANDOM_PORT;
|
|
108
|
+
const defaultEp = import_index_akash_v1beta4.Endpoint.fromPartial({
|
|
109
|
+
kind,
|
|
110
|
+
sequenceNumber: 0
|
|
111
|
+
});
|
|
112
|
+
const leasedEp = to.ip && to.ip.length > 0 ? import_index_akash_v1beta4.Endpoint.fromPartial({
|
|
113
|
+
kind: import_index_akash_v1beta4.Endpoint_Kind.LEASED_IP,
|
|
114
|
+
sequenceNumber: endpointSequenceNumbers[to.ip]
|
|
115
|
+
}) : void 0;
|
|
116
|
+
return leasedEp ? [defaultEp, leasedEp] : [defaultEp];
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
function parseCpuUnits(cpu) {
|
|
121
|
+
return typeof cpu.units === "string" ? (0, import_sizes.convertCpuResourceString)(cpu.units) : cpu.units * 1e3;
|
|
122
|
+
}
|
|
123
|
+
function parseMemoryBytes(memory) {
|
|
124
|
+
return (0, import_sizes.convertResourceString)(memory.size);
|
|
125
|
+
}
|
|
126
|
+
function parseStorageBytes(size) {
|
|
127
|
+
return (0, import_sizes.convertResourceString)(size);
|
|
128
|
+
}
|
|
129
|
+
function parseGpuUnits(gpu) {
|
|
130
|
+
const value = gpu?.units;
|
|
131
|
+
if (value === void 0 || value === null) return 0;
|
|
132
|
+
return typeof value === "string" ? parseInt(value, 10) : value;
|
|
133
|
+
}
|
|
134
|
+
function buildResourceAttributes(attributes) {
|
|
135
|
+
if (!attributes) return void 0;
|
|
136
|
+
return Object.entries(attributes).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => ({ key, value: String(value) }));
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=manifestUtils.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sdl/manifest/manifestUtils.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Attribute } from \"../../generated/protos/index.akash.v1.ts\";\nimport {\n Endpoint,\n Endpoint_Kind,\n} from \"../../generated/protos/index.akash.v1beta4.ts\";\nimport {\n ServiceExposeHTTPOptions,\n} from \"../../generated/protos/index.provider.akash.v2beta3.ts\";\nimport { convertCpuResourceString, convertResourceString } from \"../sizes.ts\";\nimport type { SDLInput } from \"../validateSDL/validateSDL.ts\";\nimport type { StorageAttributesValidation } from \"../validateSDL/validateSDLInput.ts\";\n\ntype SDLService = SDLInput[\"services\"][string];\ntype SDLExpose = NonNullable<SDLService[\"expose\"]>[number];\ntype SDLExposeTo = NonNullable<SDLExpose[\"to\"]>[number];\ntype SDLHttpOptions = SDLExpose[\"http_options\"];\ntype SDLCompute = SDLInput[\"profiles\"][\"compute\"][string];\ntype SDLStorage = SDLCompute[\"resources\"][\"storage\"];\ntype SDLStorageVolume = SDLStorage extends (infer T)[] ? T : SDLStorage;\ntype SDLGpuAttributes = NonNullable<NonNullable<SDLCompute[\"resources\"][\"gpu\"]>[\"attributes\"]>;\n\nexport type { SDLCompute, SDLExpose, SDLExposeTo, SDLGpuAttributes, SDLHttpOptions, SDLService, SDLStorage, SDLStorageVolume };\n\nconst encoder = new TextEncoder();\n\nexport function encodeResourceValue(value: number): Uint8Array {\n return encoder.encode(value.toString());\n}\n\nexport function computeEndpointSequenceNumbers(services: SDLInput[\"services\"]): Record<string, number> {\n const endpointNames: string[] = [];\n\n for (const service of Object.values(services)) {\n if (!service.expose) continue;\n for (const expose of service.expose) {\n if (!expose.to) continue;\n for (const to of expose.to) {\n if (to.global && to.ip && to.ip.length > 0) {\n endpointNames.push(to.ip);\n }\n }\n }\n }\n\n return endpointNames.sort().reduce<Record<string, number>>((result, name, seqNumber) => {\n result[name] = seqNumber + 1;\n return result;\n }, {});\n}\n\nexport function isIngress(proto: string, global: boolean, externalPort: number, port: number): boolean {\n const effectivePort = externalPort === 0 ? port : externalPort;\n return global && proto === \"TCP\" && effectivePort === 80;\n}\n\nexport function transformGpuAttributes(attributes: SDLGpuAttributes): Attribute[] {\n const vendor = attributes.vendor;\n if (!vendor) return [];\n\n return Object.entries(vendor).flatMap(([vendorName, models]) =>\n models\n ? models.map((model) => {\n let key = `vendor/${vendorName}/model/${model.model}`;\n if (model.ram) key += `/ram/${model.ram}`;\n if (model.interface) key += `/interface/${model.interface}`;\n return { key, value: \"true\" };\n })\n : [{ key: `vendor/${vendorName}/model/*`, value: \"true\" }],\n );\n}\n\nexport function buildHttpOptions(httpOptions?: SDLHttpOptions): ServiceExposeHTTPOptions {\n return ServiceExposeHTTPOptions.fromPartial({\n maxBodySize: httpOptions?.max_body_size ?? 1048576,\n readTimeout: httpOptions?.read_timeout ?? 60000,\n sendTimeout: httpOptions?.send_timeout ?? 60000,\n nextTries: httpOptions?.next_tries ?? 3,\n nextTimeout: httpOptions?.next_timeout ?? 0,\n nextCases: httpOptions?.next_cases ?? [\"error\", \"timeout\"],\n });\n}\n\nexport function buildStorageAttributes(attributes?: StorageAttributesValidation): Attribute[] {\n if (!attributes) return [];\n\n const pairs: Attribute[] = Object.entries(attributes).map(([key, value]) => ({\n key,\n value: String(value),\n }));\n\n if (attributes.class === \"ram\" && !(\"persistent\" in attributes)) {\n pairs.push({ key: \"persistent\", value: \"false\" });\n }\n\n pairs.sort((a, b) => a.key.localeCompare(b.key));\n return pairs;\n}\n\nexport function parseServiceProto(proto?: string): string {\n return proto?.toUpperCase() || \"TCP\";\n}\n\nexport function buildServiceEndpoints(\n service: SDLService,\n endpointSequenceNumbers: Record<string, number>,\n): Endpoint[] {\n return (service.expose ?? []).flatMap((expose) =>\n (expose.to ?? [])\n .filter((to) => to.global)\n .flatMap((to) => {\n const externalPort = expose.as || 0;\n const proto = parseServiceProto(expose.proto);\n const kind = isIngress(proto, !!to.global, externalPort, expose.port)\n ? Endpoint_Kind.SHARED_HTTP\n : Endpoint_Kind.RANDOM_PORT;\n\n const defaultEp = Endpoint.fromPartial({\n kind,\n sequenceNumber: 0,\n });\n\n const leasedEp = to.ip && to.ip.length > 0\n ? Endpoint.fromPartial({\n kind: Endpoint_Kind.LEASED_IP,\n sequenceNumber: endpointSequenceNumbers[to.ip],\n })\n : undefined;\n\n return leasedEp ? [defaultEp, leasedEp] : [defaultEp];\n }),\n );\n}\n\nexport function parseCpuUnits(cpu: SDLCompute[\"resources\"][\"cpu\"]): number {\n return typeof cpu.units === \"string\"\n ? convertCpuResourceString(cpu.units)\n : cpu.units * 1000;\n}\n\nexport function parseMemoryBytes(memory: SDLCompute[\"resources\"][\"memory\"]): number {\n return convertResourceString(memory.size);\n}\n\nexport function parseStorageBytes(size: string): number {\n return convertResourceString(size);\n}\n\nexport function parseGpuUnits(gpu?: SDLCompute[\"resources\"][\"gpu\"]): number {\n const value = gpu?.units;\n if (value === undefined || value === null) return 0;\n return typeof value === \"string\" ? parseInt(value, 10) : value;\n}\n\nexport function buildResourceAttributes(attributes?: Record<string, unknown>): Attribute[] | undefined {\n if (!attributes) return undefined;\n return Object.entries(attributes)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, value]) => ({ key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explicit-any */\nexport type v2Manifest = v2Group[];\n\nexport type v3Manifest = v3Group[];\n\nexport type v3Group = {\n name: string;\n services: v3ManifestService[];\n};\n\nexport type v2Group = {\n Name: string;\n Services: v2ManifestService[];\n};\n\nexport type v2ManifestService = {\n Name: string;\n Image: string;\n Command: string[] | null;\n Args: string[] | null;\n Env: string[] | null;\n Resources: ResourceUnits;\n Count: number;\n Expose: v2ServiceExpose[];\n params?: v2ManifestServiceParams;\n};\n\nexport type v3ManifestService = {\n name: string;\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n resources: ResourceUnits;\n count: number;\n expose: v3ServiceExpose[];\n params?: v3ManifestServiceParams | null;\n credentials: v2ServiceImageCredentials | null;\n};\n\nexport type v2ServiceExposeHttpOptions = {\n MaxBodySize: number;\n ReadTimeout: number;\n SendTimeout: number;\n NextTries: number;\n NextTimeout: number;\n NextCases: string[];\n};\n\nexport type v3ServiceExposeHttpOptions = {\n maxBodySize: number;\n readTimeout: number;\n sendTimeout: number;\n nextTries: number;\n nextTimeout: number;\n nextCases: string[];\n};\n\nexport type ResourceUnits = Record<string, any>;\n\nexport type v2ServiceExpose = {\n Port: number;\n ExternalPort: number;\n Proto: string;\n Service: any;\n Global: boolean;\n Hosts: any;\n HTTPOptions: v2ServiceExposeHttpOptions;\n IP: string;\n EndpointSequenceNumber: number;\n};\n\nexport type v3ServiceExpose = {\n port: number;\n externalPort: number;\n proto: string;\n service: any;\n global: boolean;\n hosts: any;\n httpOptions: v3ServiceExposeHttpOptions;\n ip: string;\n endpointSequenceNumber: number;\n};\n\ntype v2ServicePermissionsScope = \"deployment\" | \"logs\";\n\nexport type v2ServicePermissions = {\n read?: v2ServicePermissionsScope[];\n};\n\nexport type v2ManifestServiceParams = {\n Storage: v2ServiceStorageParams[];\n Permissions?: v2ServicePermissions;\n};\n\nexport type v3ManifestServiceParams = {\n storage: v2ServiceStorageParams[];\n permissions?: v2ServicePermissions;\n};\n\nexport type v2Sdl = {\n services: Record<string, v2Service>;\n profiles: v2Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\nexport type v3Sdl = {\n services: Record<string, v2Service>;\n profiles: v3Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\nexport type v2Endpoint = {\n kind: string;\n};\n\nexport type v2ExposeTo = {\n service?: string;\n global?: boolean;\n http_options: v2HTTPOptions;\n ip: string;\n};\n\nexport type v2HTTPOptions = {\n max_body_size: number;\n read_timeout: number;\n send_timeout: number;\n next_tries: number;\n next_timeout: number;\n next_cases: string[];\n};\n\nexport type v2Accept = {\n items?: string[];\n};\n\nexport type v2Expose = {\n port: number;\n as: number;\n proto?: string;\n to?: v2ExposeTo[];\n accept: v2Accept;\n http_options: v2HTTPOptions;\n};\n\nexport type v2Dependency = {\n service: string;\n};\n\nexport type v2ServiceStorageParams = {\n name: string;\n mount: string;\n readOnly: boolean;\n};\n\nexport type v2ServiceParams = {\n storage?: Record<string, v2ServiceStorageParams>;\n permissions?: v2ServicePermissions;\n};\n\nexport type v2ServiceImageCredentials = {\n host: string;\n email?: string;\n username: string;\n password: string;\n};\n\nexport type v2Service = {\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n expose: v2Expose[];\n dependencies?: v2Dependency[];\n params?: v2ServiceParams;\n credentials?: v2ServiceImageCredentials;\n};\n\nexport type v2ServiceDeployment = {\n profile: string;\n count: number;\n};\n\nexport type v2Deployment = Record<string, v2ServiceDeployment>;\n\nexport type v2CPUAttributes = Record<string, any>;\n\nexport type v2ResourceCPU = {\n units: number | string;\n attributes?: v2CPUAttributes;\n};\n\nexport type v2ResourceMemory = {\n size: string;\n attributes?: Record<string, any>;\n};\n\nexport type v3GPUAttributes = {\n vendor: {\n [vendor: string]: Array<{ model: string; ram?: string; interface?: string }>;\n };\n};\n\nexport type v3ResourceGPU = {\n units: number | string;\n attributes?: v3GPUAttributes;\n};\n\nexport type v2StorageAttributes = Record<string, any>;\n\nexport type v2ResourceStorage = {\n name: string;\n size: string;\n attributes: v2StorageAttributes;\n};\n\nexport type v2ResourceStorageArray = v2ResourceStorage[];\n\nexport type v2ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n};\n\nexport type v3ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n gpu: v3ResourceGPU;\n id: number;\n};\n\nexport type v2ProfileCompute = {\n resources: v2ComputeResources;\n};\n\nexport type v3ProfileCompute = {\n resources: v3ComputeResources;\n};\n\nexport type v2PlacementAttributes = Attributes;\n\nexport type v2Coin = {\n denom: string;\n value: number;\n amount: number;\n};\n\nexport type v2PlacementPricing = Record<string, v2Coin>;\n\nexport type SignedBy = {\n allOf: string[];\n anyOf: string[];\n};\n\nexport type v2ProfilePlacement = {\n attributes: v2PlacementAttributes;\n signedBy: SignedBy;\n pricing: v2PlacementPricing;\n};\n\nexport type v2Profiles = {\n compute: Record<string, v2ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\nexport type v3Profiles = {\n compute: Record<string, v3ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\nexport type Attribute = {\n key: string;\n value: string;\n};\n\nexport type v3DeploymentGroup = {\n name: string;\n resources: Array<{\n resource: v3ComputeResources;\n price: number;\n count: number;\n endpoints: Array<{ kind: number; sequence_number: number }>;\n }>;\n requirements: {\n attributes: Array<Attribute>;\n signedBy: {\n allOf: string[];\n anyOf: string[];\n };\n };\n};\n\nexport type Attributes = Attribute[];\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * @deprecated will be removed in favor of `Manifest` type\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type v2Manifest = v2Group[];\n\n/** @deprecated Use `Manifest` type instead. */\nexport type v3Manifest = v3Group[];\n\n/** @deprecated Use `Manifest` type instead. */\nexport type v3Group = {\n name: string;\n services: v3ManifestService[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2Group = {\n Name: string;\n Services: v2ManifestService[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ManifestService = {\n Name: string;\n Image: string;\n Command: string[] | null;\n Args: string[] | null;\n Env: string[] | null;\n Resources: ResourceUnits;\n Count: number;\n Expose: v2ServiceExpose[];\n params?: v2ManifestServiceParams;\n};\n\n/** @deprecated Use `Manifest` type instead. */\nexport type v3ManifestService = {\n name: string;\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n resources: ResourceUnits;\n count: number;\n expose: v3ServiceExpose[];\n params?: v3ManifestServiceParams | null;\n credentials: v2ServiceImageCredentials | null;\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ServiceExposeHttpOptions = {\n MaxBodySize: number;\n ReadTimeout: number;\n SendTimeout: number;\n NextTries: number;\n NextTimeout: number;\n NextCases: string[];\n};\n\n/** @deprecated Use `Manifest[number]['services'][number]['expose'][number]['httpOptions']` type instead. */\nexport type v3ServiceExposeHttpOptions = {\n maxBodySize: number;\n readTimeout: number;\n sendTimeout: number;\n nextTries: number;\n nextTimeout: number;\n nextCases: string[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type ResourceUnits = Record<string, any>;\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ServiceExpose = {\n Port: number;\n ExternalPort: number;\n Proto: string;\n Service: any;\n Global: boolean;\n Hosts: any;\n HTTPOptions: v2ServiceExposeHttpOptions;\n IP: string;\n EndpointSequenceNumber: number;\n};\n\n/** @deprecated Use `Manifest[number]['services'][number]['expose'][number]` type instead. */\nexport type v3ServiceExpose = {\n port: number;\n externalPort: number;\n proto: string;\n service: any;\n global: boolean;\n hosts: any;\n httpOptions: v3ServiceExposeHttpOptions;\n ip: string;\n endpointSequenceNumber: number;\n};\n\ntype v2ServicePermissionsScope = \"deployment\" | \"logs\";\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ServicePermissions = {\n read?: v2ServicePermissionsScope[];\n};\n\n/** @deprecated will be removed in favor of `Manifest` type. */\nexport type v2ManifestServiceParams = {\n Storage: v2ServiceStorageParams[];\n Permissions?: v2ServicePermissions;\n};\n\n/** @deprecated Use `Manifest[number]['services'][number]['params']` type instead. */\nexport type v3ManifestServiceParams = {\n storage: v2ServiceStorageParams[] | null;\n permissions?: v2ServicePermissions;\n};\n\n/** @deprecated will be removed in favor of `Manifest` type */\nexport type v2Sdl = {\n services: Record<string, v2Service>;\n profiles: v2Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\n/** @deprecated Use `SDLInput` type instead. */\nexport type v3Sdl = {\n services: Record<string, v2Service>;\n profiles: v3Profiles;\n deployment: Record<string, v2Deployment>;\n endpoints: Record<string, v2Endpoint>;\n};\n\n/** @deprecated will be removed. */\nexport type v2Endpoint = {\n kind: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ExposeTo = {\n service?: string;\n global?: boolean;\n http_options: v2HTTPOptions;\n ip: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2HTTPOptions = {\n max_body_size: number;\n read_timeout: number;\n send_timeout: number;\n next_tries: number;\n next_timeout: number;\n next_cases: string[];\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Accept = {\n items?: string[];\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Expose = {\n port: number;\n as: number;\n proto?: string;\n to?: v2ExposeTo[];\n accept: v2Accept;\n http_options: v2HTTPOptions;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Dependency = {\n service: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceStorageParams = {\n name: string;\n mount: string;\n readOnly: boolean;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceParams = {\n storage?: Record<string, v2ServiceStorageParams>;\n permissions?: v2ServicePermissions;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceImageCredentials = {\n host: string;\n email?: string;\n username: string;\n password: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Service = {\n image: string;\n command: string[] | null;\n args: string[] | null;\n env: string[] | null;\n expose: v2Expose[];\n dependencies?: v2Dependency[];\n params?: v2ServiceParams;\n credentials?: v2ServiceImageCredentials;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ServiceDeployment = {\n profile: string;\n count: number;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Deployment = Record<string, v2ServiceDeployment>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2CPUAttributes = Record<string, any>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceCPU = {\n units: number | string;\n attributes?: v2CPUAttributes;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceMemory = {\n size: string;\n attributes?: Record<string, any>;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3GPUAttributes = {\n vendor: {\n [vendor: string]: Array<{ model: string; ram?: string; interface?: string }>;\n };\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3ResourceGPU = {\n units: number | string;\n attributes?: v3GPUAttributes;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2StorageAttributes = Record<string, any>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceStorage = {\n name: string;\n size: string;\n attributes: v2StorageAttributes;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ResourceStorageArray = v2ResourceStorage[];\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3ComputeResources = {\n cpu: v2ResourceCPU;\n memory: v2ResourceMemory;\n storage: v2ResourceStorageArray | v2ResourceStorage;\n gpu: v3ResourceGPU;\n id: number;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ProfileCompute = {\n resources: v2ComputeResources;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3ProfileCompute = {\n resources: v3ComputeResources;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2PlacementAttributes = Attributes;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Coin = {\n denom: string;\n value: number;\n amount: number;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2PlacementPricing = Record<string, v2Coin>;\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type SignedBy = {\n allOf: string[];\n anyOf: string[];\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2ProfilePlacement = {\n attributes: v2PlacementAttributes;\n signedBy: SignedBy;\n pricing: v2PlacementPricing;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v2Profiles = {\n compute: Record<string, v2ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3Profiles = {\n compute: Record<string, v3ProfileCompute>;\n placement: Record<string, v2ProfilePlacement>;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type Attribute = {\n key: string;\n value: string;\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type v3DeploymentGroup = {\n name: string;\n resources: Array<{\n resource: v3ComputeResources;\n price: number;\n count: number;\n endpoints: Array<{ kind: number; sequence_number: number }>;\n }>;\n requirements: {\n attributes: Array<Attribute>;\n signedBy: {\n allOf: string[];\n anyOf: string[];\n };\n };\n};\n\n/** @deprecated will be removed in favor of `SDLInput` and `Manifest` types. */\nexport type Attributes = Attribute[];\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["
|
|
3
|
+
"sources": ["../../../src/sdl/utils.ts"],
|
|
4
4
|
"sourcesContent": ["export function castArray<T>(value: T | T[] | undefined | null): T[] {\n if (value === undefined || value === null) return [];\n return Array.isArray(value) ? value : [value];\n}\n\nexport function stringToBoolean(str: string | boolean): boolean {\n if (typeof str === \"boolean\") {\n return str;\n }\n\n switch (str.toLowerCase()) {\n case \"false\":\n case \"no\":\n case \"0\":\n case \"\":\n return false;\n default:\n return true;\n }\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,UAAa,OAAwC;AACnE,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO,CAAC;AACnD,SAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;AAEO,SAAS,gBAAgB,KAAgC;AAC9D,MAAI,OAAO,QAAQ,WAAW;AAC5B,WAAO;AAAA,EACT;AAEA,UAAQ,IAAI,YAAY,GAAG;AAAA,IACzB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;",
|
|
6
6
|
"names": []
|