ic-mops 1.7.2 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/bundle/bench/bench-canister.mo +113 -0
  3. package/bundle/bench/user-bench.mo +14 -0
  4. package/bundle/bin/moc-wrapper.sh +40 -0
  5. package/bundle/bin/mops.js +3 -0
  6. package/bundle/cli.js +14 -14
  7. package/bundle/cli.tgz +0 -0
  8. package/bundle/declarations/bench/bench.did +30 -0
  9. package/bundle/declarations/bench/bench.did.d.ts +33 -0
  10. package/bundle/declarations/bench/bench.did.js +30 -0
  11. package/bundle/declarations/bench/index.d.ts +50 -0
  12. package/bundle/declarations/bench/index.js +40 -0
  13. package/bundle/declarations/main/index.d.ts +50 -0
  14. package/bundle/declarations/main/index.js +40 -0
  15. package/bundle/declarations/main/main.did +465 -0
  16. package/bundle/declarations/main/main.did.d.ts +392 -0
  17. package/bundle/declarations/main/main.did.js +454 -0
  18. package/bundle/declarations/storage/index.d.ts +50 -0
  19. package/bundle/declarations/storage/index.js +30 -0
  20. package/bundle/declarations/storage/storage.did +46 -0
  21. package/bundle/declarations/storage/storage.did.d.ts +40 -0
  22. package/bundle/declarations/storage/storage.did.js +38 -0
  23. package/bundle/package.json +35 -0
  24. package/bundle/templates/README.md +13 -0
  25. package/bundle/templates/licenses/Apache-2.0 +202 -0
  26. package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
  27. package/bundle/templates/licenses/MIT +21 -0
  28. package/bundle/templates/mops-publish.yml +17 -0
  29. package/bundle/templates/mops-test.yml +24 -0
  30. package/bundle/templates/src/lib.mo +15 -0
  31. package/bundle/templates/test/lib.test.mo +4 -0
  32. package/bundle/wasm_bg.wasm +0 -0
  33. package/cli.ts +16 -0
  34. package/commands/format.ts +169 -0
  35. package/commands/publish.ts +1 -0
  36. package/commands/watch/formatter.ts +74 -0
  37. package/commands/watch/watch.ts +23 -2
  38. package/dist/cli.js +15 -0
  39. package/dist/commands/format.d.ts +14 -0
  40. package/dist/commands/format.js +131 -0
  41. package/dist/commands/publish.js +1 -0
  42. package/dist/commands/watch/formatter.d.ts +19 -0
  43. package/dist/commands/watch/formatter.js +57 -0
  44. package/dist/commands/watch/watch.d.ts +1 -0
  45. package/dist/commands/watch/watch.js +19 -1
  46. package/dist/package.json +4 -2
  47. package/package.json +6 -4
  48. package/types.ts +10 -0
@@ -0,0 +1,454 @@
1
+ export const idlFactory = ({ IDL }) => {
2
+ const PackageName__1 = IDL.Text;
3
+ const Result_3 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
4
+ const PublishingId = IDL.Text;
5
+ const Err = IDL.Text;
6
+ const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
7
+ const Text = IDL.Text;
8
+ const PackageVersion__1 = IDL.Text;
9
+ const PackageId = IDL.Text;
10
+ const Time = IDL.Int;
11
+ const DownloadsSnapshot__1 = IDL.Record({
12
+ 'startTime' : Time,
13
+ 'endTime' : Time,
14
+ 'downloads' : IDL.Nat,
15
+ });
16
+ const FileId = IDL.Text;
17
+ const Result_8 = IDL.Variant({
18
+ 'ok' : IDL.Vec(IDL.Tuple(FileId, IDL.Vec(IDL.Nat8))),
19
+ 'err' : Err,
20
+ });
21
+ const Result_7 = IDL.Variant({ 'ok' : IDL.Vec(FileId), 'err' : Err });
22
+ const SemverPart = IDL.Variant({
23
+ 'major' : IDL.Null,
24
+ 'minor' : IDL.Null,
25
+ 'patch' : IDL.Null,
26
+ });
27
+ const Result_6 = IDL.Variant({
28
+ 'ok' : IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1)),
29
+ 'err' : Err,
30
+ });
31
+ const Result_5 = IDL.Variant({ 'ok' : PackageVersion__1, 'err' : Err });
32
+ const User = IDL.Record({
33
+ 'id' : IDL.Principal,
34
+ 'emailVerified' : IDL.Bool,
35
+ 'twitter' : IDL.Text,
36
+ 'displayName' : IDL.Text,
37
+ 'name' : IDL.Text,
38
+ 'site' : IDL.Text,
39
+ 'email' : IDL.Text,
40
+ 'twitterVerified' : IDL.Bool,
41
+ 'githubVerified' : IDL.Bool,
42
+ 'github' : IDL.Text,
43
+ });
44
+ const DepsStatus = IDL.Variant({
45
+ 'allLatest' : IDL.Null,
46
+ 'tooOld' : IDL.Null,
47
+ 'updatesAvailable' : IDL.Null,
48
+ });
49
+ const PackageQuality = IDL.Record({
50
+ 'depsStatus' : DepsStatus,
51
+ 'hasDescription' : IDL.Bool,
52
+ 'hasKeywords' : IDL.Bool,
53
+ 'hasLicense' : IDL.Bool,
54
+ 'hasDocumentation' : IDL.Bool,
55
+ 'hasTests' : IDL.Bool,
56
+ 'hasRepository' : IDL.Bool,
57
+ 'hasReleaseNotes' : IDL.Bool,
58
+ });
59
+ const PackageVersion = IDL.Text;
60
+ const Script = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
61
+ const PackageName = IDL.Text;
62
+ const DependencyV2 = IDL.Record({
63
+ 'name' : PackageName,
64
+ 'repo' : IDL.Text,
65
+ 'version' : IDL.Text,
66
+ });
67
+ const Requirement = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
68
+ const PackageConfigV3 = IDL.Record({
69
+ 'dfx' : IDL.Text,
70
+ 'moc' : IDL.Text,
71
+ 'scripts' : IDL.Vec(Script),
72
+ 'baseDir' : IDL.Text,
73
+ 'documentation' : IDL.Text,
74
+ 'name' : PackageName,
75
+ 'homepage' : IDL.Text,
76
+ 'description' : IDL.Text,
77
+ 'version' : IDL.Text,
78
+ 'keywords' : IDL.Vec(IDL.Text),
79
+ 'donation' : IDL.Text,
80
+ 'devDependencies' : IDL.Vec(DependencyV2),
81
+ 'repository' : IDL.Text,
82
+ 'dependencies' : IDL.Vec(DependencyV2),
83
+ 'requirements' : IDL.Vec(Requirement),
84
+ 'license' : IDL.Text,
85
+ 'readme' : IDL.Text,
86
+ });
87
+ const PackagePublication = IDL.Record({
88
+ 'storage' : IDL.Principal,
89
+ 'time' : Time,
90
+ 'user' : IDL.Principal,
91
+ });
92
+ const PackageSummary = IDL.Record({
93
+ 'ownerInfo' : User,
94
+ 'owners' : IDL.Vec(User),
95
+ 'maintainers' : IDL.Vec(User),
96
+ 'owner' : IDL.Principal,
97
+ 'depAlias' : IDL.Text,
98
+ 'quality' : PackageQuality,
99
+ 'publisher' : User,
100
+ 'highestVersion' : PackageVersion,
101
+ 'downloadsTotal' : IDL.Nat,
102
+ 'downloadsInLast30Days' : IDL.Nat,
103
+ 'downloadsInLast7Days' : IDL.Nat,
104
+ 'config' : PackageConfigV3,
105
+ 'publication' : PackagePublication,
106
+ });
107
+ const BenchmarkMetric = IDL.Text;
108
+ const Benchmark = IDL.Record({
109
+ 'gc' : IDL.Text,
110
+ 'metrics' : IDL.Vec(IDL.Tuple(BenchmarkMetric, IDL.Vec(IDL.Vec(IDL.Int)))),
111
+ 'cols' : IDL.Vec(IDL.Text),
112
+ 'file' : IDL.Text,
113
+ 'name' : IDL.Text,
114
+ 'rows' : IDL.Vec(IDL.Text),
115
+ 'description' : IDL.Text,
116
+ 'compilerVersion' : IDL.Text,
117
+ 'compiler' : IDL.Text,
118
+ 'replica' : IDL.Text,
119
+ 'replicaVersion' : IDL.Text,
120
+ 'forceGC' : IDL.Bool,
121
+ });
122
+ const Benchmarks__1 = IDL.Vec(Benchmark);
123
+ const PackageSummary__1 = IDL.Record({
124
+ 'ownerInfo' : User,
125
+ 'owners' : IDL.Vec(User),
126
+ 'maintainers' : IDL.Vec(User),
127
+ 'owner' : IDL.Principal,
128
+ 'depAlias' : IDL.Text,
129
+ 'quality' : PackageQuality,
130
+ 'publisher' : User,
131
+ 'highestVersion' : PackageVersion,
132
+ 'downloadsTotal' : IDL.Nat,
133
+ 'downloadsInLast30Days' : IDL.Nat,
134
+ 'downloadsInLast7Days' : IDL.Nat,
135
+ 'config' : PackageConfigV3,
136
+ 'publication' : PackagePublication,
137
+ });
138
+ const TestStats__1 = IDL.Record({
139
+ 'passedNames' : IDL.Vec(IDL.Text),
140
+ 'passed' : IDL.Nat,
141
+ });
142
+ const DownloadsSnapshot = IDL.Record({
143
+ 'startTime' : Time,
144
+ 'endTime' : Time,
145
+ 'downloads' : IDL.Nat,
146
+ });
147
+ const PackageFileStatsPublic = IDL.Record({
148
+ 'sourceFiles' : IDL.Nat,
149
+ 'sourceSize' : IDL.Nat,
150
+ });
151
+ const TestsChanges = IDL.Record({
152
+ 'addedNames' : IDL.Vec(IDL.Text),
153
+ 'removedNames' : IDL.Vec(IDL.Text),
154
+ });
155
+ const DepChange = IDL.Record({
156
+ 'oldVersion' : IDL.Text,
157
+ 'name' : IDL.Text,
158
+ 'newVersion' : IDL.Text,
159
+ });
160
+ const PackageChanges = IDL.Record({
161
+ 'tests' : TestsChanges,
162
+ 'deps' : IDL.Vec(DepChange),
163
+ 'curBenchmarks' : Benchmarks__1,
164
+ 'prevBenchmarks' : Benchmarks__1,
165
+ 'notes' : IDL.Text,
166
+ 'devDeps' : IDL.Vec(DepChange),
167
+ });
168
+ const PackageSummaryWithChanges__1 = IDL.Record({
169
+ 'ownerInfo' : User,
170
+ 'owners' : IDL.Vec(User),
171
+ 'maintainers' : IDL.Vec(User),
172
+ 'owner' : IDL.Principal,
173
+ 'depAlias' : IDL.Text,
174
+ 'quality' : PackageQuality,
175
+ 'publisher' : User,
176
+ 'highestVersion' : PackageVersion,
177
+ 'downloadsTotal' : IDL.Nat,
178
+ 'downloadsInLast30Days' : IDL.Nat,
179
+ 'downloadsInLast7Days' : IDL.Nat,
180
+ 'config' : PackageConfigV3,
181
+ 'changes' : PackageChanges,
182
+ 'publication' : PackagePublication,
183
+ });
184
+ const PackageDetails = IDL.Record({
185
+ 'benchmarks' : Benchmarks__1,
186
+ 'ownerInfo' : User,
187
+ 'owners' : IDL.Vec(User),
188
+ 'maintainers' : IDL.Vec(User),
189
+ 'owner' : IDL.Principal,
190
+ 'depAlias' : IDL.Text,
191
+ 'deps' : IDL.Vec(PackageSummary__1),
192
+ 'quality' : PackageQuality,
193
+ 'publisher' : User,
194
+ 'testStats' : TestStats__1,
195
+ 'highestVersion' : PackageVersion,
196
+ 'downloadsTotal' : IDL.Nat,
197
+ 'downloadsInLast30Days' : IDL.Nat,
198
+ 'downloadTrend' : IDL.Vec(DownloadsSnapshot),
199
+ 'fileStats' : PackageFileStatsPublic,
200
+ 'versionHistory' : IDL.Vec(PackageSummaryWithChanges__1),
201
+ 'dependents' : IDL.Vec(PackageSummary__1),
202
+ 'devDeps' : IDL.Vec(PackageSummary__1),
203
+ 'downloadsInLast7Days' : IDL.Nat,
204
+ 'config' : PackageConfigV3,
205
+ 'changes' : PackageChanges,
206
+ 'publication' : PackagePublication,
207
+ });
208
+ const Result_4 = IDL.Variant({ 'ok' : PackageDetails, 'err' : Err });
209
+ const PackageSummaryWithChanges = IDL.Record({
210
+ 'ownerInfo' : User,
211
+ 'owners' : IDL.Vec(User),
212
+ 'maintainers' : IDL.Vec(User),
213
+ 'owner' : IDL.Principal,
214
+ 'depAlias' : IDL.Text,
215
+ 'quality' : PackageQuality,
216
+ 'publisher' : User,
217
+ 'highestVersion' : PackageVersion,
218
+ 'downloadsTotal' : IDL.Nat,
219
+ 'downloadsInLast30Days' : IDL.Nat,
220
+ 'downloadsInLast7Days' : IDL.Nat,
221
+ 'config' : PackageConfigV3,
222
+ 'changes' : PackageChanges,
223
+ 'publication' : PackagePublication,
224
+ });
225
+ const StorageId = IDL.Principal;
226
+ const StorageStats = IDL.Record({
227
+ 'fileCount' : IDL.Nat,
228
+ 'cyclesBalance' : IDL.Nat,
229
+ 'memorySize' : IDL.Nat,
230
+ });
231
+ const User__1 = IDL.Record({
232
+ 'id' : IDL.Principal,
233
+ 'emailVerified' : IDL.Bool,
234
+ 'twitter' : IDL.Text,
235
+ 'displayName' : IDL.Text,
236
+ 'name' : IDL.Text,
237
+ 'site' : IDL.Text,
238
+ 'email' : IDL.Text,
239
+ 'twitterVerified' : IDL.Bool,
240
+ 'githubVerified' : IDL.Bool,
241
+ 'github' : IDL.Text,
242
+ });
243
+ const Header = IDL.Tuple(IDL.Text, IDL.Text);
244
+ const Request = IDL.Record({
245
+ 'url' : IDL.Text,
246
+ 'method' : IDL.Text,
247
+ 'body' : IDL.Vec(IDL.Nat8),
248
+ 'headers' : IDL.Vec(Header),
249
+ 'certificate_version' : IDL.Opt(IDL.Nat16),
250
+ });
251
+ const StreamingToken = IDL.Vec(IDL.Nat8);
252
+ const StreamingCallbackResponse = IDL.Record({
253
+ 'token' : IDL.Opt(StreamingToken),
254
+ 'body' : IDL.Vec(IDL.Nat8),
255
+ });
256
+ const StreamingCallback = IDL.Func(
257
+ [StreamingToken],
258
+ [IDL.Opt(StreamingCallbackResponse)],
259
+ ['query'],
260
+ );
261
+ const StreamingStrategy = IDL.Variant({
262
+ 'Callback' : IDL.Record({
263
+ 'token' : StreamingToken,
264
+ 'callback' : StreamingCallback,
265
+ }),
266
+ });
267
+ const Response = IDL.Record({
268
+ 'body' : IDL.Vec(IDL.Nat8),
269
+ 'headers' : IDL.Vec(Header),
270
+ 'upgrade' : IDL.Opt(IDL.Bool),
271
+ 'streaming_strategy' : IDL.Opt(StreamingStrategy),
272
+ 'status_code' : IDL.Nat16,
273
+ });
274
+ const PageCount = IDL.Nat;
275
+ const Result_2 = IDL.Variant({ 'ok' : FileId, 'err' : Err });
276
+ const PackageConfigV3_Publishing = IDL.Record({
277
+ 'dfx' : IDL.Text,
278
+ 'moc' : IDL.Text,
279
+ 'scripts' : IDL.Vec(Script),
280
+ 'baseDir' : IDL.Text,
281
+ 'documentation' : IDL.Text,
282
+ 'name' : PackageName,
283
+ 'homepage' : IDL.Text,
284
+ 'description' : IDL.Text,
285
+ 'version' : IDL.Text,
286
+ 'keywords' : IDL.Vec(IDL.Text),
287
+ 'donation' : IDL.Text,
288
+ 'devDependencies' : IDL.Vec(DependencyV2),
289
+ 'repository' : IDL.Text,
290
+ 'dependencies' : IDL.Vec(DependencyV2),
291
+ 'requirements' : IDL.Opt(IDL.Vec(Requirement)),
292
+ 'license' : IDL.Text,
293
+ 'readme' : IDL.Text,
294
+ });
295
+ const Result_1 = IDL.Variant({ 'ok' : PublishingId, 'err' : Err });
296
+ const HttpHeader = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
297
+ const HttpResponse = IDL.Record({
298
+ 'status' : IDL.Nat,
299
+ 'body' : IDL.Vec(IDL.Nat8),
300
+ 'headers' : IDL.Vec(HttpHeader),
301
+ });
302
+ const HttpTransformArg = IDL.Record({
303
+ 'context' : IDL.Vec(IDL.Nat8),
304
+ 'response' : HttpResponse,
305
+ });
306
+ const Benchmarks = IDL.Vec(Benchmark);
307
+ const TestStats = IDL.Record({
308
+ 'passedNames' : IDL.Vec(IDL.Text),
309
+ 'passed' : IDL.Nat,
310
+ });
311
+ const Main = IDL.Service({
312
+ 'addMaintainer' : IDL.Func([PackageName__1, IDL.Principal], [Result_3], []),
313
+ 'addOwner' : IDL.Func([PackageName__1, IDL.Principal], [Result_3], []),
314
+ 'backup' : IDL.Func([], [], []),
315
+ 'computeHashesForExistingFiles' : IDL.Func([], [], []),
316
+ 'finishPublish' : IDL.Func([PublishingId], [Result], []),
317
+ 'getApiVersion' : IDL.Func([], [Text], ['query']),
318
+ 'getBackupCanisterId' : IDL.Func([], [IDL.Principal], ['query']),
319
+ 'getDefaultPackages' : IDL.Func(
320
+ [IDL.Text],
321
+ [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1))],
322
+ ['query'],
323
+ ),
324
+ 'getDownloadTrendByPackageId' : IDL.Func(
325
+ [PackageId],
326
+ [IDL.Vec(DownloadsSnapshot__1)],
327
+ ['query'],
328
+ ),
329
+ 'getDownloadTrendByPackageName' : IDL.Func(
330
+ [PackageName__1],
331
+ [IDL.Vec(DownloadsSnapshot__1)],
332
+ ['query'],
333
+ ),
334
+ 'getFileHashes' : IDL.Func(
335
+ [PackageName__1, PackageVersion__1],
336
+ [Result_8],
337
+ [],
338
+ ),
339
+ 'getFileHashesByPackageIds' : IDL.Func(
340
+ [IDL.Vec(PackageId)],
341
+ [
342
+ IDL.Vec(
343
+ IDL.Tuple(PackageId, IDL.Vec(IDL.Tuple(FileId, IDL.Vec(IDL.Nat8))))
344
+ ),
345
+ ],
346
+ [],
347
+ ),
348
+ 'getFileHashesQuery' : IDL.Func(
349
+ [PackageName__1, PackageVersion__1],
350
+ [Result_8],
351
+ ['query'],
352
+ ),
353
+ 'getFileIds' : IDL.Func(
354
+ [PackageName__1, PackageVersion__1],
355
+ [Result_7],
356
+ ['query'],
357
+ ),
358
+ 'getHighestSemverBatch' : IDL.Func(
359
+ [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1, SemverPart))],
360
+ [Result_6],
361
+ ['query'],
362
+ ),
363
+ 'getHighestVersion' : IDL.Func([PackageName__1], [Result_5], ['query']),
364
+ 'getMostDownloadedPackages' : IDL.Func(
365
+ [],
366
+ [IDL.Vec(PackageSummary)],
367
+ ['query'],
368
+ ),
369
+ 'getMostDownloadedPackagesIn7Days' : IDL.Func(
370
+ [],
371
+ [IDL.Vec(PackageSummary)],
372
+ ['query'],
373
+ ),
374
+ 'getNewPackages' : IDL.Func([], [IDL.Vec(PackageSummary)], ['query']),
375
+ 'getPackageDetails' : IDL.Func(
376
+ [PackageName__1, PackageVersion__1],
377
+ [Result_4],
378
+ ['query'],
379
+ ),
380
+ 'getPackageMaintainers' : IDL.Func(
381
+ [PackageName__1],
382
+ [IDL.Vec(IDL.Principal)],
383
+ ['query'],
384
+ ),
385
+ 'getPackageOwners' : IDL.Func(
386
+ [PackageName__1],
387
+ [IDL.Vec(IDL.Principal)],
388
+ ['query'],
389
+ ),
390
+ 'getPackagesByCategory' : IDL.Func(
391
+ [],
392
+ [IDL.Vec(IDL.Tuple(IDL.Text, IDL.Vec(PackageSummary)))],
393
+ ['query'],
394
+ ),
395
+ 'getRecentlyUpdatedPackages' : IDL.Func(
396
+ [],
397
+ [IDL.Vec(PackageSummaryWithChanges)],
398
+ ['query'],
399
+ ),
400
+ 'getStoragesStats' : IDL.Func(
401
+ [],
402
+ [IDL.Vec(IDL.Tuple(StorageId, StorageStats))],
403
+ ['query'],
404
+ ),
405
+ 'getTotalDownloads' : IDL.Func([], [IDL.Nat], ['query']),
406
+ 'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
407
+ 'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User__1)], ['query']),
408
+ 'http_request' : IDL.Func([Request], [Response], ['query']),
409
+ 'notifyInstall' : IDL.Func(
410
+ [PackageName__1, PackageVersion__1],
411
+ [],
412
+ ['oneway'],
413
+ ),
414
+ 'notifyInstalls' : IDL.Func(
415
+ [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion__1))],
416
+ [],
417
+ ['oneway'],
418
+ ),
419
+ 'removeMaintainer' : IDL.Func(
420
+ [PackageName__1, IDL.Principal],
421
+ [Result_3],
422
+ [],
423
+ ),
424
+ 'removeOwner' : IDL.Func([PackageName__1, IDL.Principal], [Result_3], []),
425
+ 'restore' : IDL.Func([IDL.Nat], [], []),
426
+ 'search' : IDL.Func(
427
+ [Text, IDL.Opt(IDL.Nat), IDL.Opt(IDL.Nat)],
428
+ [IDL.Vec(PackageSummary), PageCount],
429
+ ['query'],
430
+ ),
431
+ 'setUserProp' : IDL.Func([IDL.Text, IDL.Text], [Result_3], []),
432
+ 'startFileUpload' : IDL.Func(
433
+ [PublishingId, Text, IDL.Nat, IDL.Vec(IDL.Nat8)],
434
+ [Result_2],
435
+ [],
436
+ ),
437
+ 'startPublish' : IDL.Func([PackageConfigV3_Publishing], [Result_1], []),
438
+ 'transformRequest' : IDL.Func(
439
+ [HttpTransformArg],
440
+ [HttpResponse],
441
+ ['query'],
442
+ ),
443
+ 'uploadBenchmarks' : IDL.Func([PublishingId, Benchmarks], [Result], []),
444
+ 'uploadFileChunk' : IDL.Func(
445
+ [PublishingId, FileId, IDL.Nat, IDL.Vec(IDL.Nat8)],
446
+ [Result],
447
+ [],
448
+ ),
449
+ 'uploadNotes' : IDL.Func([PublishingId, IDL.Text], [Result], []),
450
+ 'uploadTestStats' : IDL.Func([PublishingId, TestStats], [Result], []),
451
+ });
452
+ return Main;
453
+ };
454
+ export const init = ({ IDL }) => { return []; };
@@ -0,0 +1,50 @@
1
+ import type {
2
+ ActorSubclass,
3
+ HttpAgentOptions,
4
+ ActorConfig,
5
+ Agent,
6
+ } from "@dfinity/agent";
7
+ import type { Principal } from "@dfinity/principal";
8
+ import type { IDL } from "@dfinity/candid";
9
+
10
+ import { _SERVICE } from './storage.did';
11
+
12
+ export declare const idlFactory: IDL.InterfaceFactory;
13
+ export declare const canisterId: string;
14
+
15
+ export declare interface CreateActorOptions {
16
+ /**
17
+ * @see {@link Agent}
18
+ */
19
+ agent?: Agent;
20
+ /**
21
+ * @see {@link HttpAgentOptions}
22
+ */
23
+ agentOptions?: HttpAgentOptions;
24
+ /**
25
+ * @see {@link ActorConfig}
26
+ */
27
+ actorOptions?: ActorConfig;
28
+ }
29
+
30
+ /**
31
+ * Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
32
+ * @constructs {@link ActorSubClass}
33
+ * @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
34
+ * @param {CreateActorOptions} options - see {@link CreateActorOptions}
35
+ * @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
36
+ * @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
37
+ * @see {@link HttpAgentOptions}
38
+ * @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
39
+ * @see {@link ActorConfig}
40
+ */
41
+ export declare const createActor: (
42
+ canisterId: string | Principal,
43
+ options?: CreateActorOptions
44
+ ) => ActorSubclass<_SERVICE>;
45
+
46
+ /**
47
+ * Intialized Actor using default settings, ready to talk to a canister using its candid interface
48
+ * @constructs {@link ActorSubClass}
49
+ */
50
+ export declare const storage: ActorSubclass<_SERVICE>;
@@ -0,0 +1,30 @@
1
+ import { Actor, HttpAgent } from "@dfinity/agent";
2
+
3
+ // Imports and re-exports candid interface
4
+ import { idlFactory } from './storage.did.js';
5
+ export { idlFactory } from './storage.did.js';
6
+
7
+ /**
8
+ *
9
+ * @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent
10
+ * @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig}} [options]
11
+ * @return {import("@dfinity/agent").ActorSubclass<import("./storage.did.js")._SERVICE>}
12
+ */
13
+ export const createActor = (canisterId, options) => {
14
+ const agent = new HttpAgent({ ...options?.agentOptions });
15
+
16
+ // Fetch root key for certificate validation during development
17
+ if(process.env.NODE_ENV !== "production") {
18
+ agent.fetchRootKey().catch(err=>{
19
+ console.warn("Unable to fetch root key. Check to ensure that your local replica is running");
20
+ console.error(err);
21
+ });
22
+ }
23
+
24
+ // Creates an actor with using the candid interface and the HttpAgent
25
+ return Actor.createActor(idlFactory, {
26
+ agent,
27
+ canisterId,
28
+ ...options?.actorOptions,
29
+ });
30
+ };
@@ -0,0 +1,46 @@
1
+ type StorageStats =
2
+ record {
3
+ cyclesBalance: nat;
4
+ fileCount: nat;
5
+ memorySize: nat;
6
+ };
7
+ type Storage =
8
+ service {
9
+ acceptCycles: () -> ();
10
+ deleteFile: (FileId) -> ();
11
+ downloadChunk: (FileId, nat) -> (Result_2) query;
12
+ finishUpload: (FileId) -> ();
13
+ getFileIdsRange: (nat, nat) -> (vec FileId) query;
14
+ getFileMeta: (FileId) -> (Result_1) query;
15
+ getStats: () -> (StorageStats) query;
16
+ startUpload: (FileMeta) -> (Result);
17
+ updateFileOwners: (FileId, vec principal) -> ();
18
+ uploadChunk: (FileId, nat, Chunk) -> ();
19
+ };
20
+ type Result_2 =
21
+ variant {
22
+ err: Err;
23
+ ok: Chunk;
24
+ };
25
+ type Result_1 =
26
+ variant {
27
+ err: Err;
28
+ ok: FileMeta;
29
+ };
30
+ type Result =
31
+ variant {
32
+ err: Err;
33
+ ok;
34
+ };
35
+ type FileMeta =
36
+ record {
37
+ chunkCount: nat;
38
+ id: FileId__1;
39
+ owners: vec principal;
40
+ path: text;
41
+ };
42
+ type FileId__1 = text;
43
+ type FileId = text;
44
+ type Err = text;
45
+ type Chunk = blob;
46
+ service : () -> Storage
@@ -0,0 +1,40 @@
1
+ import type { Principal } from '@dfinity/principal';
2
+ import type { ActorMethod } from '@dfinity/agent';
3
+ import type { IDL } from '@dfinity/candid';
4
+
5
+ export type Chunk = Array<number>;
6
+ export type Err = string;
7
+ export type FileId = string;
8
+ export type FileId__1 = string;
9
+ export interface FileMeta {
10
+ 'id' : FileId__1,
11
+ 'owners' : Array<Principal>,
12
+ 'path' : string,
13
+ 'chunkCount' : bigint,
14
+ }
15
+ export type Result = { 'ok' : null } |
16
+ { 'err' : Err };
17
+ export type Result_1 = { 'ok' : FileMeta } |
18
+ { 'err' : Err };
19
+ export type Result_2 = { 'ok' : Chunk } |
20
+ { 'err' : Err };
21
+ export interface Storage {
22
+ 'acceptCycles' : ActorMethod<[], undefined>,
23
+ 'deleteFile' : ActorMethod<[FileId], undefined>,
24
+ 'downloadChunk' : ActorMethod<[FileId, bigint], Result_2>,
25
+ 'finishUpload' : ActorMethod<[FileId], undefined>,
26
+ 'getFileIdsRange' : ActorMethod<[bigint, bigint], Array<FileId>>,
27
+ 'getFileMeta' : ActorMethod<[FileId], Result_1>,
28
+ 'getStats' : ActorMethod<[], StorageStats>,
29
+ 'startUpload' : ActorMethod<[FileMeta], Result>,
30
+ 'updateFileOwners' : ActorMethod<[FileId, Array<Principal>], undefined>,
31
+ 'uploadChunk' : ActorMethod<[FileId, bigint, Chunk], undefined>,
32
+ }
33
+ export interface StorageStats {
34
+ 'fileCount' : bigint,
35
+ 'cyclesBalance' : bigint,
36
+ 'memorySize' : bigint,
37
+ }
38
+ export interface _SERVICE extends Storage {}
39
+ export declare const idlFactory: IDL.InterfaceFactory;
40
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
@@ -0,0 +1,38 @@
1
+ export const idlFactory = ({ IDL }) => {
2
+ const FileId = IDL.Text;
3
+ const Chunk = IDL.Vec(IDL.Nat8);
4
+ const Err = IDL.Text;
5
+ const Result_2 = IDL.Variant({ 'ok' : Chunk, 'err' : Err });
6
+ const FileId__1 = IDL.Text;
7
+ const FileMeta = IDL.Record({
8
+ 'id' : FileId__1,
9
+ 'owners' : IDL.Vec(IDL.Principal),
10
+ 'path' : IDL.Text,
11
+ 'chunkCount' : IDL.Nat,
12
+ });
13
+ const Result_1 = IDL.Variant({ 'ok' : FileMeta, 'err' : Err });
14
+ const StorageStats = IDL.Record({
15
+ 'fileCount' : IDL.Nat,
16
+ 'cyclesBalance' : IDL.Nat,
17
+ 'memorySize' : IDL.Nat,
18
+ });
19
+ const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
20
+ const Storage = IDL.Service({
21
+ 'acceptCycles' : IDL.Func([], [], []),
22
+ 'deleteFile' : IDL.Func([FileId], [], []),
23
+ 'downloadChunk' : IDL.Func([FileId, IDL.Nat], [Result_2], ['query']),
24
+ 'finishUpload' : IDL.Func([FileId], [], []),
25
+ 'getFileIdsRange' : IDL.Func(
26
+ [IDL.Nat, IDL.Nat],
27
+ [IDL.Vec(FileId)],
28
+ ['query'],
29
+ ),
30
+ 'getFileMeta' : IDL.Func([FileId], [Result_1], ['query']),
31
+ 'getStats' : IDL.Func([], [StorageStats], ['query']),
32
+ 'startUpload' : IDL.Func([FileMeta], [Result], []),
33
+ 'updateFileOwners' : IDL.Func([FileId, IDL.Vec(IDL.Principal)], [], []),
34
+ 'uploadChunk' : IDL.Func([FileId, IDL.Nat, Chunk], [], []),
35
+ });
36
+ return Storage;
37
+ };
38
+ export const init = ({ IDL }) => { return []; };
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "ic-mops",
3
+ "version": "1.7.2",
4
+ "type": "module",
5
+ "bin": {
6
+ "mops": "bin/mops.js",
7
+ "ic-mops": "bin/mops.js",
8
+ "moc-wrapper": "bin/moc-wrapper.sh"
9
+ },
10
+ "files": [
11
+ "*",
12
+ "!network.txt",
13
+ "!Dockerfile",
14
+ "!verify.sh",
15
+ "!build.sh",
16
+ "!DEVELOPMENT.md",
17
+ "!.mops",
18
+ "/templates"
19
+ ],
20
+ "homepage": "https://mops.one",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/ZenVoich/mops.git"
24
+ },
25
+ "author": "Zen Voich <zen.voich@gmail.com>",
26
+ "license": "MIT",
27
+ "engines": {
28
+ "node": ">=18.0.0"
29
+ },
30
+ "dependencies": {
31
+ "dhall-to-json-cli": "1.7.6",
32
+ "decomp-tarxz": "0.1.1",
33
+ "buffer": "6.0.3"
34
+ }
35
+ }