ic-mops 2.1.0 → 2.2.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 (118) hide show
  1. package/.DS_Store +0 -0
  2. package/CHANGELOG.md +8 -0
  3. package/RELEASE.md +19 -0
  4. package/bundle/bench/bench-canister.mo +130 -0
  5. package/bundle/bench/user-bench.mo +10 -0
  6. package/bundle/bin/moc-wrapper.sh +40 -0
  7. package/bundle/bin/mops.js +3 -0
  8. package/bundle/cli.js +1569 -0
  9. package/bundle/cli.tgz +0 -0
  10. package/bundle/declarations/bench/bench.did +30 -0
  11. package/bundle/declarations/bench/bench.did.d.ts +33 -0
  12. package/bundle/declarations/bench/bench.did.js +30 -0
  13. package/bundle/declarations/bench/index.d.ts +50 -0
  14. package/bundle/declarations/bench/index.js +40 -0
  15. package/bundle/declarations/main/index.d.ts +50 -0
  16. package/bundle/declarations/main/index.js +40 -0
  17. package/bundle/declarations/main/main.did +428 -0
  18. package/bundle/declarations/main/main.did.d.ts +348 -0
  19. package/bundle/declarations/main/main.did.js +406 -0
  20. package/bundle/declarations/storage/index.d.ts +50 -0
  21. package/bundle/declarations/storage/index.js +30 -0
  22. package/bundle/declarations/storage/storage.did +46 -0
  23. package/bundle/declarations/storage/storage.did.d.ts +40 -0
  24. package/bundle/declarations/storage/storage.did.js +38 -0
  25. package/bundle/default-stylesheet.css +415 -0
  26. package/bundle/package.json +36 -0
  27. package/bundle/templates/README.md +13 -0
  28. package/bundle/templates/licenses/Apache-2.0 +202 -0
  29. package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
  30. package/bundle/templates/licenses/MIT +21 -0
  31. package/bundle/templates/mops-publish.yml +17 -0
  32. package/bundle/templates/mops-test.yml +24 -0
  33. package/bundle/templates/src/lib.mo +15 -0
  34. package/bundle/templates/test/lib.test.mo +4 -0
  35. package/bundle/wasm_bg.wasm +0 -0
  36. package/bundle/xhr-sync-worker.js +51 -0
  37. package/cli.ts +15 -0
  38. package/commands/bench.ts +11 -3
  39. package/commands/build.ts +3 -2
  40. package/commands/check.ts +4 -0
  41. package/commands/test/test.ts +3 -1
  42. package/commands/toolchain/index.ts +4 -0
  43. package/commands/watch/error-checker.ts +8 -2
  44. package/commands/watch/warning-checker.ts +8 -2
  45. package/dist/cli.js +13 -1
  46. package/dist/commands/bench.js +5 -4
  47. package/dist/commands/build.js +3 -2
  48. package/dist/commands/check.js +4 -0
  49. package/dist/commands/test/test.js +3 -1
  50. package/dist/commands/toolchain/index.js +3 -0
  51. package/dist/commands/watch/error-checker.js +8 -2
  52. package/dist/commands/watch/warning-checker.js +8 -2
  53. package/dist/error.d.ts +1 -1
  54. package/dist/helpers/autofix-motoko.js +84 -39
  55. package/dist/mops.d.ts +1 -0
  56. package/dist/mops.js +10 -4
  57. package/dist/package.json +6 -7
  58. package/dist/tests/check-fix.test.js +16 -0
  59. package/dist/tests/check.test.js +4 -0
  60. package/dist/tests/moc-args.test.d.ts +1 -0
  61. package/dist/tests/moc-args.test.js +17 -0
  62. package/dist/tests/toolchain.test.js +11 -0
  63. package/dist/types.d.ts +3 -0
  64. package/dist/wasm/pkg/bundler/package.json +20 -0
  65. package/dist/wasm/pkg/bundler/wasm.d.ts +3 -0
  66. package/dist/wasm/pkg/bundler/wasm.js +5 -0
  67. package/dist/wasm/pkg/bundler/wasm_bg.js +93 -0
  68. package/dist/wasm/pkg/bundler/wasm_bg.wasm +0 -0
  69. package/dist/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
  70. package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
  71. package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
  72. package/error.ts +1 -1
  73. package/helpers/autofix-motoko.ts +119 -49
  74. package/mops.ts +13 -6
  75. package/package.json +8 -9
  76. package/tests/__snapshots__/check-fix.test.ts.snap +25 -6
  77. package/tests/__snapshots__/check.test.ts.snap +9 -0
  78. package/tests/build/success/.dfx/local/canister_ids.json +17 -0
  79. package/tests/build/success/.dfx/local/canisters/bar/bar.did +3 -0
  80. package/tests/build/success/.dfx/local/canisters/bar/bar.most +4 -0
  81. package/tests/build/success/.dfx/local/canisters/bar/bar.wasm +0 -0
  82. package/tests/build/success/.dfx/local/canisters/bar/constructor.did +3 -0
  83. package/tests/build/success/.dfx/local/canisters/bar/index.js +42 -0
  84. package/tests/build/success/.dfx/local/canisters/bar/init_args.txt +1 -0
  85. package/tests/build/success/.dfx/local/canisters/bar/service.did +3 -0
  86. package/tests/build/success/.dfx/local/canisters/bar/service.did.d.ts +7 -0
  87. package/tests/build/success/.dfx/local/canisters/bar/service.did.js +4 -0
  88. package/tests/build/success/.dfx/local/canisters/foo/constructor.did +3 -0
  89. package/tests/build/success/.dfx/local/canisters/foo/foo.did +3 -0
  90. package/tests/build/success/.dfx/local/canisters/foo/foo.most +4 -0
  91. package/tests/build/success/.dfx/local/canisters/foo/foo.wasm +0 -0
  92. package/tests/build/success/.dfx/local/canisters/foo/index.js +42 -0
  93. package/tests/build/success/.dfx/local/canisters/foo/init_args.txt +1 -0
  94. package/tests/build/success/.dfx/local/canisters/foo/service.did +3 -0
  95. package/tests/build/success/.dfx/local/canisters/foo/service.did.d.ts +7 -0
  96. package/tests/build/success/.dfx/local/canisters/foo/service.did.js +4 -0
  97. package/tests/build/success/.dfx/local/lsp/ucwa4-rx777-77774-qaada-cai.did +3 -0
  98. package/tests/build/success/.dfx/local/lsp/ulvla-h7777-77774-qaacq-cai.did +3 -0
  99. package/tests/build/success/.dfx/local/network-id +4 -0
  100. package/tests/check/fix/overlapping.mo +10 -0
  101. package/tests/check/moc-args/Warning.mo +5 -0
  102. package/tests/check/moc-args/mops.toml +2 -0
  103. package/tests/check-fix.test.ts +23 -0
  104. package/tests/check.test.ts +5 -0
  105. package/tests/moc-args.test.ts +19 -0
  106. package/tests/toolchain-local-subpath/bin/moc +2 -0
  107. package/tests/toolchain-local-subpath/mops.toml +2 -0
  108. package/tests/toolchain.test.ts +13 -0
  109. package/types.ts +3 -0
  110. package/wasm/Cargo.lock +54 -101
  111. package/wasm/pkg/bundler/package.json +20 -0
  112. package/wasm/pkg/bundler/wasm.d.ts +3 -0
  113. package/wasm/pkg/bundler/wasm.js +5 -0
  114. package/wasm/pkg/bundler/wasm_bg.js +93 -0
  115. package/wasm/pkg/bundler/wasm_bg.wasm +0 -0
  116. package/wasm/pkg/bundler/wasm_bg.wasm.d.ts +8 -0
  117. package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
  118. package/wasm/pkg/web/wasm_bg.wasm +0 -0
@@ -0,0 +1,348 @@
1
+ import type { Principal } from '@icp-sdk/core/principal';
2
+ import type { ActorMethod } from '@icp-sdk/core/agent';
3
+ import type { IDL } from '@icp-sdk/core/candid';
4
+
5
+ export interface Benchmark {
6
+ 'gc' : string,
7
+ 'metrics' : Array<[BenchmarkMetric, Array<Array<bigint>>]>,
8
+ 'cols' : Array<string>,
9
+ 'file' : string,
10
+ 'name' : string,
11
+ 'rows' : Array<string>,
12
+ 'description' : string,
13
+ 'compilerVersion' : string,
14
+ 'compiler' : string,
15
+ 'replica' : string,
16
+ 'replicaVersion' : string,
17
+ 'forceGC' : boolean,
18
+ }
19
+ export type BenchmarkMetric = string;
20
+ export type Benchmarks = Array<Benchmark>;
21
+ export interface DepChange {
22
+ 'oldVersion' : string,
23
+ 'name' : string,
24
+ 'newVersion' : string,
25
+ }
26
+ export interface DependencyV2 {
27
+ 'name' : PackageName,
28
+ 'repo' : string,
29
+ 'version' : string,
30
+ }
31
+ export type DepsStatus = { 'allLatest' : null } |
32
+ { 'tooOld' : null } |
33
+ { 'updatesAvailable' : null };
34
+ export interface DownloadsSnapshot {
35
+ 'startTime' : Time,
36
+ 'endTime' : Time,
37
+ 'downloads' : bigint,
38
+ }
39
+ export type Err = string;
40
+ export type FileId = string;
41
+ export type Header = [string, string];
42
+ export interface HttpHeader { 'value' : string, 'name' : string }
43
+ export interface HttpRequestResult {
44
+ 'status' : bigint,
45
+ 'body' : Uint8Array | number[],
46
+ 'headers' : Array<HttpHeader>,
47
+ }
48
+ export interface Main {
49
+ 'addMaintainer' : ActorMethod<[PackageName, Principal], Result_3>,
50
+ 'addOwner' : ActorMethod<[PackageName, Principal], Result_3>,
51
+ 'backup' : ActorMethod<[], undefined>,
52
+ 'computeHashesForExistingFiles' : ActorMethod<[], undefined>,
53
+ 'finishPublish' : ActorMethod<[PublishingId], Result>,
54
+ 'getApiVersion' : ActorMethod<[], Text>,
55
+ 'getBackupCanisterId' : ActorMethod<[], Principal>,
56
+ 'getDefaultPackages' : ActorMethod<
57
+ [string],
58
+ Array<[PackageName, PackageVersion]>
59
+ >,
60
+ 'getDownloadTrendByPackageId' : ActorMethod<
61
+ [PackageId],
62
+ Array<DownloadsSnapshot>
63
+ >,
64
+ 'getDownloadTrendByPackageName' : ActorMethod<
65
+ [PackageName],
66
+ Array<DownloadsSnapshot>
67
+ >,
68
+ 'getFileHashes' : ActorMethod<[PackageName, PackageVersion], Result_8>,
69
+ 'getFileHashesByPackageIds' : ActorMethod<
70
+ [Array<PackageId>],
71
+ Array<[PackageId, Array<[FileId, Uint8Array | number[]]>]>
72
+ >,
73
+ 'getFileHashesQuery' : ActorMethod<[PackageName, PackageVersion], Result_8>,
74
+ 'getFileIds' : ActorMethod<[PackageName, PackageVersion], Result_7>,
75
+ 'getHighestSemverBatch' : ActorMethod<
76
+ [Array<[PackageName, PackageVersion, SemverPart]>],
77
+ Result_6
78
+ >,
79
+ 'getHighestVersion' : ActorMethod<[PackageName], Result_5>,
80
+ 'getMostDownloadedPackages' : ActorMethod<[], Array<PackageSummary>>,
81
+ 'getMostDownloadedPackagesIn7Days' : ActorMethod<[], Array<PackageSummary>>,
82
+ 'getNewPackages' : ActorMethod<[], Array<PackageSummary>>,
83
+ 'getPackageDependents' : ActorMethod<
84
+ [PackageName, bigint, bigint],
85
+ [Array<PackageSummary>, bigint]
86
+ >,
87
+ 'getPackageDetails' : ActorMethod<[PackageName, PackageVersion], Result_4>,
88
+ 'getPackageMaintainers' : ActorMethod<[PackageName], Array<Principal>>,
89
+ 'getPackageOwners' : ActorMethod<[PackageName], Array<Principal>>,
90
+ 'getPackageVersionHistory' : ActorMethod<
91
+ [PackageName],
92
+ Array<PackageSummaryWithChanges>
93
+ >,
94
+ 'getPackagesByCategory' : ActorMethod<
95
+ [],
96
+ Array<[string, Array<PackageSummary>]>
97
+ >,
98
+ 'getRecentlyUpdatedPackages' : ActorMethod<
99
+ [],
100
+ Array<PackageSummaryWithChanges>
101
+ >,
102
+ 'getStoragesStats' : ActorMethod<[], Array<[StorageId, StorageStats]>>,
103
+ 'getTotalDownloads' : ActorMethod<[], bigint>,
104
+ 'getTotalPackages' : ActorMethod<[], bigint>,
105
+ 'getUser' : ActorMethod<[Principal], [] | [User]>,
106
+ 'http_request' : ActorMethod<[Request], Response>,
107
+ 'notifyInstall' : ActorMethod<[PackageName, PackageVersion], undefined>,
108
+ 'notifyInstalls' : ActorMethod<
109
+ [Array<[PackageName, PackageVersion]>],
110
+ undefined
111
+ >,
112
+ 'removeMaintainer' : ActorMethod<[PackageName, Principal], Result_3>,
113
+ 'removeOwner' : ActorMethod<[PackageName, Principal], Result_3>,
114
+ 'restore' : ActorMethod<[bigint], undefined>,
115
+ 'search' : ActorMethod<
116
+ [Text, [] | [bigint], [] | [bigint]],
117
+ [Array<PackageSummary>, PageCount]
118
+ >,
119
+ 'setStorageControllers' : ActorMethod<[], undefined>,
120
+ 'setUserProp' : ActorMethod<[string, string], Result_3>,
121
+ 'startFileUpload' : ActorMethod<
122
+ [PublishingId, Text, bigint, Uint8Array | number[]],
123
+ Result_2
124
+ >,
125
+ 'startPublish' : ActorMethod<[PackageConfigV3_Publishing], Result_1>,
126
+ 'takeSnapshotsIfNeeded' : ActorMethod<[], undefined>,
127
+ 'transformRequest' : ActorMethod<[TransformArg], HttpRequestResult>,
128
+ 'uploadBenchmarks' : ActorMethod<[PublishingId, Benchmarks], Result>,
129
+ 'uploadDocsCoverage' : ActorMethod<[PublishingId, number], Result>,
130
+ 'uploadFileChunk' : ActorMethod<
131
+ [PublishingId, FileId, bigint, Uint8Array | number[]],
132
+ Result
133
+ >,
134
+ 'uploadNotes' : ActorMethod<[PublishingId, string], Result>,
135
+ 'uploadTestStats' : ActorMethod<[PublishingId, TestStats], Result>,
136
+ }
137
+ export interface PackageChanges {
138
+ 'tests' : TestsChanges,
139
+ 'deps' : Array<DepChange>,
140
+ 'curBenchmarks' : Benchmarks,
141
+ 'prevDocsCoverage' : number,
142
+ 'prevBenchmarks' : Benchmarks,
143
+ 'notes' : string,
144
+ 'curDocsCoverage' : number,
145
+ 'devDeps' : Array<DepChange>,
146
+ }
147
+ export interface PackageConfigV3 {
148
+ 'dfx' : string,
149
+ 'moc' : string,
150
+ 'scripts' : Array<Script>,
151
+ 'baseDir' : string,
152
+ 'documentation' : string,
153
+ 'name' : PackageName,
154
+ 'homepage' : string,
155
+ 'description' : string,
156
+ 'version' : string,
157
+ 'keywords' : Array<string>,
158
+ 'donation' : string,
159
+ 'devDependencies' : Array<DependencyV2>,
160
+ 'repository' : string,
161
+ 'dependencies' : Array<DependencyV2>,
162
+ 'requirements' : Array<Requirement>,
163
+ 'license' : string,
164
+ 'readme' : string,
165
+ }
166
+ export interface PackageConfigV3_Publishing {
167
+ 'dfx' : string,
168
+ 'moc' : string,
169
+ 'scripts' : Array<Script>,
170
+ 'baseDir' : string,
171
+ 'documentation' : string,
172
+ 'name' : PackageName,
173
+ 'homepage' : string,
174
+ 'description' : string,
175
+ 'version' : string,
176
+ 'keywords' : Array<string>,
177
+ 'donation' : string,
178
+ 'devDependencies' : Array<DependencyV2>,
179
+ 'repository' : string,
180
+ 'dependencies' : Array<DependencyV2>,
181
+ 'requirements' : [] | [Array<Requirement>],
182
+ 'license' : string,
183
+ 'readme' : string,
184
+ }
185
+ export interface PackageDetails {
186
+ 'benchmarks' : Benchmarks,
187
+ 'ownerInfo' : User,
188
+ 'owners' : Array<User>,
189
+ 'maintainers' : Array<User>,
190
+ 'owner' : Principal,
191
+ 'depAlias' : string,
192
+ 'deps' : Array<PackageSummary>,
193
+ 'quality' : PackageQuality,
194
+ 'publisher' : User,
195
+ 'testStats' : TestStats,
196
+ 'docsCoverage' : number,
197
+ 'highestVersion' : PackageVersion,
198
+ 'downloadsTotal' : bigint,
199
+ 'downloadsInLast30Days' : bigint,
200
+ 'dependentsCount' : bigint,
201
+ 'downloadTrend' : Array<DownloadsSnapshot>,
202
+ 'fileStats' : PackageFileStatsPublic,
203
+ 'versionHistory' : Array<PackageSummaryWithChanges>,
204
+ 'dependents' : Array<PackageSummary>,
205
+ 'devDeps' : Array<PackageSummary>,
206
+ 'downloadsInLast7Days' : bigint,
207
+ 'config' : PackageConfigV3,
208
+ 'changes' : PackageChanges,
209
+ 'versions' : Array<PackageVersion>,
210
+ 'publication' : PackagePublication,
211
+ }
212
+ export interface PackageFileStatsPublic {
213
+ 'sourceFiles' : bigint,
214
+ 'sourceSize' : bigint,
215
+ }
216
+ export type PackageId = string;
217
+ export type PackageName = string;
218
+ export interface PackagePublication {
219
+ 'storage' : Principal,
220
+ 'time' : Time,
221
+ 'user' : Principal,
222
+ }
223
+ export interface PackageQuality {
224
+ 'depsStatus' : DepsStatus,
225
+ 'docsCoverage' : number,
226
+ 'hasDescription' : boolean,
227
+ 'hasKeywords' : boolean,
228
+ 'hasLicense' : boolean,
229
+ 'hasDocumentation' : boolean,
230
+ 'hasTests' : boolean,
231
+ 'hasRepository' : boolean,
232
+ 'hasReleaseNotes' : boolean,
233
+ }
234
+ export interface PackageSummary {
235
+ 'ownerInfo' : User,
236
+ 'owners' : Array<User>,
237
+ 'maintainers' : Array<User>,
238
+ 'owner' : Principal,
239
+ 'depAlias' : string,
240
+ 'quality' : PackageQuality,
241
+ 'publisher' : User,
242
+ 'highestVersion' : PackageVersion,
243
+ 'downloadsTotal' : bigint,
244
+ 'downloadsInLast30Days' : bigint,
245
+ 'downloadsInLast7Days' : bigint,
246
+ 'config' : PackageConfigV3,
247
+ 'publication' : PackagePublication,
248
+ }
249
+ export interface PackageSummaryWithChanges {
250
+ 'ownerInfo' : User,
251
+ 'owners' : Array<User>,
252
+ 'maintainers' : Array<User>,
253
+ 'owner' : Principal,
254
+ 'depAlias' : string,
255
+ 'quality' : PackageQuality,
256
+ 'publisher' : User,
257
+ 'highestVersion' : PackageVersion,
258
+ 'downloadsTotal' : bigint,
259
+ 'downloadsInLast30Days' : bigint,
260
+ 'downloadsInLast7Days' : bigint,
261
+ 'config' : PackageConfigV3,
262
+ 'changes' : PackageChanges,
263
+ 'publication' : PackagePublication,
264
+ }
265
+ export type PackageVersion = string;
266
+ export type PageCount = bigint;
267
+ export type PublishingId = string;
268
+ export interface Request {
269
+ 'url' : string,
270
+ 'method' : string,
271
+ 'body' : Uint8Array | number[],
272
+ 'headers' : Array<Header>,
273
+ 'certificate_version' : [] | [number],
274
+ }
275
+ export interface Requirement { 'value' : string, 'name' : string }
276
+ export interface Response {
277
+ 'body' : Uint8Array | number[],
278
+ 'headers' : Array<Header>,
279
+ 'upgrade' : [] | [boolean],
280
+ 'streaming_strategy' : [] | [StreamingStrategy],
281
+ 'status_code' : number,
282
+ }
283
+ export type Result = { 'ok' : null } |
284
+ { 'err' : Err };
285
+ export type Result_1 = { 'ok' : PublishingId } |
286
+ { 'err' : Err };
287
+ export type Result_2 = { 'ok' : FileId } |
288
+ { 'err' : Err };
289
+ export type Result_3 = { 'ok' : null } |
290
+ { 'err' : string };
291
+ export type Result_4 = { 'ok' : PackageDetails } |
292
+ { 'err' : Err };
293
+ export type Result_5 = { 'ok' : PackageVersion } |
294
+ { 'err' : Err };
295
+ export type Result_6 = { 'ok' : Array<[PackageName, PackageVersion]> } |
296
+ { 'err' : Err };
297
+ export type Result_7 = { 'ok' : Array<FileId> } |
298
+ { 'err' : Err };
299
+ export type Result_8 = { 'ok' : Array<[FileId, Uint8Array | number[]]> } |
300
+ { 'err' : Err };
301
+ export interface Script { 'value' : string, 'name' : string }
302
+ export type SemverPart = { 'major' : null } |
303
+ { 'minor' : null } |
304
+ { 'patch' : null };
305
+ export type StorageId = Principal;
306
+ export interface StorageStats {
307
+ 'fileCount' : bigint,
308
+ 'cyclesBalance' : bigint,
309
+ 'memorySize' : bigint,
310
+ }
311
+ export type StreamingCallback = ActorMethod<
312
+ [StreamingToken],
313
+ [] | [StreamingCallbackResponse]
314
+ >;
315
+ export interface StreamingCallbackResponse {
316
+ 'token' : [] | [StreamingToken],
317
+ 'body' : Uint8Array | number[],
318
+ }
319
+ export type StreamingStrategy = {
320
+ 'Callback' : { 'token' : StreamingToken, 'callback' : StreamingCallback }
321
+ };
322
+ export type StreamingToken = Uint8Array | number[];
323
+ export interface TestStats { 'passedNames' : Array<string>, 'passed' : bigint }
324
+ export interface TestsChanges {
325
+ 'addedNames' : Array<string>,
326
+ 'removedNames' : Array<string>,
327
+ }
328
+ export type Text = string;
329
+ export type Time = bigint;
330
+ export interface TransformArg {
331
+ 'context' : Uint8Array | number[],
332
+ 'response' : HttpRequestResult,
333
+ }
334
+ export interface User {
335
+ 'id' : Principal,
336
+ 'emailVerified' : boolean,
337
+ 'twitter' : string,
338
+ 'displayName' : string,
339
+ 'name' : string,
340
+ 'site' : string,
341
+ 'email' : string,
342
+ 'twitterVerified' : boolean,
343
+ 'githubVerified' : boolean,
344
+ 'github' : string,
345
+ }
346
+ export interface _SERVICE extends Main {}
347
+ export declare const idlFactory: IDL.InterfaceFactory;
348
+ export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];