ic-mops 0.23.0 → 0.24.0

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 CHANGED
@@ -17,28 +17,16 @@ npm i -g ic-mops
17
17
 
18
18
  ## Install Packages
19
19
 
20
- ### 1. Configure dfx.json
21
- Add `mops` as a packtool to your `dfx.json`
22
-
23
- ```json
24
- {
25
- "defaults": {
26
- "build": {
27
- "packtool": "mops sources"
28
- }
29
- }
30
- }
31
- ```
32
-
33
- ### 2. Initialize
20
+ ### 1. Initialize
34
21
  Run this command in the root directory of your project (where is `dfx.json` placed)
22
+
35
23
  If there are Vessel config files, mops will migrate packages from `vessel.dhall` to `mops.toml`
36
24
 
37
25
  ```
38
26
  mops init
39
27
  ```
40
28
 
41
- ### 3. Install Motoko Packages
29
+ ### 2. Install Motoko Packages
42
30
  Use `mops add <package_name>` to install a specific package and save it to `mops.toml`
43
31
 
44
32
  ```
@@ -65,7 +53,7 @@ Use `mops install` to install all packages specified in `mops.toml`
65
53
  mops install
66
54
  ```
67
55
 
68
- ### 4. Import Package
56
+ ### 3. Import Package
69
57
  Now you can import installed packages in your Motoko code
70
58
 
71
59
  ```motoko
@@ -92,10 +80,10 @@ mops import-identity -- "$(dfx identity export mops)"
92
80
  ```
93
81
 
94
82
  ### 2. Initialize
95
- Run this command in your package root
83
+ Run this command in your package root and select type "Package"
96
84
 
97
85
  ```
98
- mops init <your_package_name>
86
+ mops init
99
87
  ```
100
88
 
101
89
  Edit `description` and `repository` fields in `mops.toml` file.
package/cli.ts CHANGED
@@ -32,10 +32,11 @@ program.version(`CLI ${packageJson.version}\nAPI ${apiVersion}`, '-v --version')
32
32
 
33
33
  // init
34
34
  program
35
- .command('init [name]')
36
- .description('Create mops.toml')
37
- .action(async (name: string) => {
38
- await init(name);
35
+ .command('init')
36
+ .description('Initialize a new project or package in the current directory')
37
+ .option('-y, --yes', 'Accept all defaults')
38
+ .action(async (options) => {
39
+ await init(options);
39
40
  });
40
41
 
41
42
  // add
@@ -111,7 +112,7 @@ program
111
112
  program
112
113
  .command('set-network <network>')
113
114
  .alias('sn')
114
- .description('Set network local|dev|ic')
115
+ .description('Set network local|staging|ic')
115
116
  .action(async (network) => {
116
117
  await setNetwork(network);
117
118
  console.log(`Selected '${network}' network`);
package/commands/init.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  import {execSync} from 'node:child_process';
2
2
  import path from 'node:path';
3
- import fs from 'node:fs';
3
+ import {existsSync, readFileSync, writeFileSync} from 'node:fs';
4
4
  import chalk from 'chalk';
5
- import {checkApiCompatibility, mainActor, readDfxJson, writeConfig} from '../mops.js';
5
+ import prompts from 'prompts';
6
+
7
+ import {checkApiCompatibility, mainActor, writeConfig} from '../mops.js';
6
8
  import {installAll} from './install-all.js';
7
9
  import {VesselConfig, readVesselConfig} from '../vessel.js';
8
10
  import {Config, Dependencies} from '../types.js';
11
+ import {template} from './template.js';
9
12
 
10
- export async function init(name = '') {
13
+ export async function init({yes = false} = {}) {
11
14
  let configFile = path.join(process.cwd(), 'mops.toml');
12
- let exists = fs.existsSync(configFile);
15
+ let exists = existsSync(configFile);
13
16
  if (exists) {
14
17
  console.log(chalk.yellow('mops.toml already exists'));
15
18
  return;
@@ -18,56 +21,179 @@ export async function init(name = '') {
18
21
  console.log('Initializing...');
19
22
 
20
23
  let config: Config = {};
21
- let vesselConfig: VesselConfig = {dependencies: [], 'dev-dependencies': []};
22
- let deps: Dependencies = {};
23
24
 
24
- const vesselFile = path.join(process.cwd(), 'vessel.dhall');
25
+ if (yes) {
26
+ await applyInit({
27
+ type: 'project',
28
+ config,
29
+ setupWorkflow: true,
30
+ addTest: false,
31
+ copyrightOwner: '',
32
+ });
33
+ return;
34
+ }
35
+
36
+ // migrate from vessel
37
+ let vesselFile = path.join(process.cwd(), 'vessel.dhall');
38
+ let vesselConfig: VesselConfig = {dependencies: [], 'dev-dependencies': []};
25
39
 
26
- if (fs.existsSync(vesselFile)) {
40
+ if (existsSync(vesselFile)) {
27
41
  console.log('Reading vessel.dhall file');
28
- const res = await readVesselConfig(process.cwd(), {cache: false});
42
+ let res = await readVesselConfig(process.cwd(), {cache: false});
29
43
  if (res) {
30
44
  vesselConfig = {...res};
31
45
  }
32
46
  }
33
47
 
34
48
  if (vesselConfig.dependencies) {
49
+ let deps: Dependencies = {};
35
50
  deps = {};
36
51
 
37
52
  for (const dep of (vesselConfig.dependencies || [])) {
38
53
  deps[dep.name] = dep;
39
54
  }
55
+
56
+ if (Object.keys(deps).length) {
57
+ config.dependencies = deps;
58
+ }
40
59
  }
41
60
 
42
- // lib mode
43
- if (name) {
61
+ let promptsConfig = {
62
+ onCancel() {
63
+ console.log('aborted');
64
+ process.exit(0);
65
+ }
66
+ };
67
+
68
+ // type
69
+ let {type} = await prompts({
70
+ type: 'select',
71
+ name: 'type',
72
+ message: 'Select type:',
73
+ choices: [
74
+ {title: `Project ${chalk.dim('(I just want to use mops packages in my project)')}`, value: 'project'},
75
+ {title: `Package ${chalk.dim('(I plan to publish this package on mops)')}`, value: 'package'},
76
+ ],
77
+ }, promptsConfig);
78
+
79
+ let addTest = false;
80
+ let copyrightOwner = '';
81
+
82
+ // package details
83
+ if (type === 'package') {
84
+ let res = await prompts([
85
+ {
86
+ type: 'text',
87
+ name: 'name',
88
+ message: 'Enter package name:',
89
+ initial: '',
90
+ },
91
+ {
92
+ type: 'text',
93
+ name: 'description',
94
+ message: 'Enter package description:',
95
+ initial: '',
96
+ },
97
+ {
98
+ type: 'text',
99
+ name: 'repository',
100
+ message: 'Enter package repository url:',
101
+ initial: '',
102
+ },
103
+ {
104
+ type: 'text',
105
+ name: 'keywords',
106
+ message: 'Enter keywords separated by spaces:',
107
+ initial: '',
108
+ },
109
+ {
110
+ type: 'select',
111
+ name: 'license',
112
+ message: 'Choose a license:',
113
+ choices: [
114
+ {title: 'MIT', value: 'MIT'},
115
+ {title: 'Apache-2.0', value: 'Apache-2.0'},
116
+ ],
117
+ initial: 0,
118
+ },
119
+ {
120
+ type: 'text',
121
+ name: 'copyrightOwner',
122
+ message: 'Enter license copyright owner:',
123
+ initial: '',
124
+ },
125
+ {
126
+ type: 'confirm',
127
+ name: 'addTest',
128
+ message: `Add example test file? ${chalk.dim('(test/lib.test.mo)')}`,
129
+ initial: true,
130
+ },
131
+ ], promptsConfig);
132
+
44
133
  config.package = {
45
- name,
46
- version: '0.1.0',
47
- description: '',
48
- repository: '',
134
+ name: (res.name || '').trim(),
135
+ version: '1.0.0',
136
+ description: (res.description || '').trim(),
137
+ repository: (res.repository || '').trim(),
138
+ keywords: [...new Set(res.keywords.split(' ').filter(Boolean))] as string[],
139
+ license: (res.license || '').trim(),
49
140
  };
50
141
 
51
- if (deps) {
52
- config.dependencies = deps;
53
- }
142
+ addTest = res.addTest;
143
+ copyrightOwner = res.copyrightOwner;
144
+ }
145
+
146
+ // GitHub workflow
147
+ let {setupWorkflow} = await prompts({
148
+ type: 'confirm',
149
+ name: 'setupWorkflow',
150
+ message: `Setup GitHub workflow? ${chalk.dim('(run `mops test` on push)')}`,
151
+ initial: true,
152
+ }, promptsConfig);
153
+
154
+ await applyInit({
155
+ type,
156
+ config,
157
+ setupWorkflow,
158
+ addTest,
159
+ copyrightOwner,
160
+ });
161
+ }
54
162
 
55
- writeConfig(config, configFile);
163
+ type ApplyInitOptions = {
164
+ type: 'project' | 'package';
165
+ config: Config;
166
+ setupWorkflow: boolean;
167
+ addTest: boolean;
168
+ copyrightOwner: string;
169
+ }
56
170
 
57
- if (Object.keys(config.dependencies || {}).length) {
58
- await installAll({verbose: true});
171
+ async function applyInit({type, config, setupWorkflow, addTest, copyrightOwner} : ApplyInitOptions) {
172
+ // set packtool in dfx.json
173
+ let dfxJson = path.resolve(process.cwd(), 'dfx.json');
174
+ let dfxJsonData;
175
+ if (existsSync(dfxJson)) {
176
+ let dfxJsonText = readFileSync(dfxJson).toString();
177
+ dfxJsonData = JSON.parse(dfxJsonText);
178
+ console.log('Setting packtool in dfx.json...');
179
+ dfxJsonData.defaults = dfxJsonData.defaults || {};
180
+ dfxJsonData.defaults.build = dfxJsonData.defaults.build || {};
181
+ if (dfxJsonData.defaults.build.packtool !== 'mops sources') {
182
+ dfxJsonData.defaults.build.packtool = 'mops sources';
183
+ let indent = dfxJsonText.match(/([ \t]+)"/)?.[1] || ' ';
184
+ writeFileSync(path.join(process.cwd(), 'dfx.json'), JSON.stringify(dfxJsonData, null, indent));
185
+ console.log(chalk.green('packtool set to "mops sources"'));
59
186
  }
60
187
  }
61
188
 
62
- // project mode
63
- if (!name) {
189
+ // get default packages
190
+ if (type === 'project') {
64
191
  let compatible = await checkApiCompatibility();
65
192
  if (!compatible) {
66
193
  return;
67
194
  }
68
195
 
69
- let dfxJson = readDfxJson();
70
- let dfxVersion = dfxJson?.dfx || '';
196
+ let dfxVersion = dfxJsonData?.dfx || '';
71
197
  if (!dfxVersion) {
72
198
  try {
73
199
  let res = execSync('dfx --version').toString();
@@ -79,6 +205,7 @@ export async function init(name = '') {
79
205
  catch {}
80
206
  }
81
207
 
208
+ console.log(`Fetching default packages for dfx ${dfxVersion}...`);
82
209
  let actor = await mainActor();
83
210
  let defaultPackages = await actor.getDefaultPackages(dfxVersion);
84
211
 
@@ -86,18 +213,57 @@ export async function init(name = '') {
86
213
  config.dependencies = {};
87
214
  }
88
215
 
89
- if (deps) {
90
- config.dependencies = deps;
91
- }
92
-
93
216
  for (let [name, version] of defaultPackages) {
94
217
  config.dependencies[name] = {name, version};
95
218
  }
219
+ }
220
+
221
+ // save config
222
+ let configFile = path.join(process.cwd(), 'mops.toml');
223
+ writeConfig(config, configFile);
224
+ console.log(chalk.green('Created'), 'mops.toml');
225
+
226
+ // add src/lib.mo
227
+ if (type === 'package' && !existsSync(path.join(process.cwd(), 'src'))) {
228
+ await template('lib.mo');
229
+ }
230
+
231
+ // add src/lib.test.mo
232
+ if (addTest && !existsSync(path.join(process.cwd(), 'test'))) {
233
+ await template('lib.test.mo');
234
+ }
235
+
236
+ // add license
237
+ if (config.package?.license) {
238
+ await template(`license:${config.package.license}`, {copyrightOwner});
239
+ }
240
+
241
+ // add readme
242
+ if (type === 'package') {
243
+ await template('readme');
244
+ }
96
245
 
97
- writeConfig(config, configFile);
246
+ // add GitHub workflow
247
+ if (setupWorkflow) {
248
+ await template('github-workflow:mops-test');
249
+ }
250
+
251
+ // add .mops to .gitignore
252
+ {
253
+ let gitignore = path.join(process.cwd(), '.gitignore');
254
+ let gitignoreData = existsSync(gitignore) ? readFileSync(gitignore).toString() : '';
255
+ let lf = gitignoreData.endsWith('\n') ? '\n' : '';
256
+ if (!gitignoreData.includes('.mops')) {
257
+ writeFileSync(gitignore, `${gitignoreData}\n.mops${lf}`.trimStart());
258
+ console.log(chalk.green('Added'), '.mops to .gitignore');
259
+ }
260
+ }
98
261
 
262
+ // install deps
263
+ if (Object.keys(config.dependencies || {}).length) {
264
+ console.log('Installing dependencies...');
99
265
  await installAll({verbose: true});
100
266
  }
101
267
 
102
- console.log(chalk.green('mops.toml has been created'));
268
+ console.log(chalk.green('Done!'));
103
269
  }
@@ -2,29 +2,97 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import chalk from 'chalk';
4
4
  import prompts from 'prompts';
5
- import {getRootDir} from '../mops.js';
5
+ import camelCase from 'camelcase';
6
+ import {getRootDir, readConfig} from '../mops.js';
6
7
 
7
- export async function template() {
8
- let res = await prompts({
9
- type: 'select',
10
- name: 'value',
11
- message: 'Select template:',
12
- choices: [
13
- {title: 'GitHub Workflow to run \'mops test\'', value: 'github-workflow:mops-test'},
14
- {title: '× Cancel', value: ''},
15
- ],
16
- initial: 0,
17
- });
8
+ export async function template(templateName?: string, options: any = {}) {
9
+ if (!templateName) {
10
+ let res = await prompts({
11
+ type: 'select',
12
+ name: 'value',
13
+ message: 'Select template:',
14
+ choices: [
15
+ {title: 'README.md', value: 'readme'},
16
+ {title: 'src/lib.mo', value: 'lib.mo'},
17
+ {title: 'test/lib.test.mo', value: 'lib.test.mo'},
18
+ {title: 'License MIT', value: 'license:MIT'},
19
+ {title: 'License Apache-2.0', value: 'license:Apache-2.0'},
20
+ {title: 'GitHub Workflow to run \'mops test\'', value: 'github-workflow:mops-test'},
21
+ {title: '× Cancel', value: ''},
22
+ ],
23
+ initial: 0,
24
+ });
25
+ templateName = res.value;
26
+ }
18
27
 
19
- if (res.value === 'github-workflow:mops-test') {
28
+ if (templateName === 'github-workflow:mops-test') {
20
29
  let dest = path.resolve(getRootDir(), '.github/workflows/mops-test.yml');
21
30
  if (fs.existsSync(dest)) {
22
- console.log(chalk.yellow('Workflow already exists:'), dest);
31
+ console.log(chalk.yellow('Workflow already exists:'), path.relative(getRootDir(), dest));
23
32
  return;
24
33
  }
25
34
  let mopsTestYml = new URL('../templates/mops-test.yml', import.meta.url);
26
35
  fs.mkdirSync(path.resolve(getRootDir(), '.github/workflows'), {recursive: true});
27
36
  fs.copyFileSync(mopsTestYml, dest);
28
- console.log(chalk.green('Workflow created:'), dest);
37
+ console.log(chalk.green('Created'), path.relative(getRootDir(), dest));
38
+ }
39
+ else if (templateName?.startsWith('license:')) {
40
+ let dest = path.resolve(getRootDir(), 'LICENSE');
41
+ if (fs.existsSync(dest)) {
42
+ console.log(chalk.yellow('LICENSE already exists'));
43
+ return;
44
+ }
45
+
46
+ let setYearAndOwner = (file: string) => {
47
+ let license = fs.readFileSync(file).toString();
48
+ license = license.replace(/<year>/g, new Date().getFullYear().toString());
49
+ if (options.copyrightOwner) {
50
+ license = license.replace(/<copyright-owner>/g, options.copyrightOwner);
51
+ }
52
+ fs.writeFileSync(file, license);
53
+ };
54
+
55
+ if (templateName === 'license:MIT') {
56
+ fs.copyFileSync(new URL('../templates/licenses/MIT', import.meta.url), path.resolve(getRootDir(), 'LICENSE'));
57
+ setYearAndOwner(path.resolve(getRootDir(), 'LICENSE'));
58
+ console.log(chalk.green('Created'), path.relative(getRootDir(), 'LICENSE'));
59
+ }
60
+ else if (templateName === 'license:Apache-2.0') {
61
+ fs.copyFileSync(new URL('../templates/licenses/Apache-2.0', import.meta.url), path.resolve(getRootDir(), 'LICENSE'));
62
+ fs.copyFileSync(new URL('../templates/licenses/Apache-2.0-NOTICE', import.meta.url), path.resolve(getRootDir(), 'NOTICE'));
63
+ setYearAndOwner(path.resolve(getRootDir(), 'NOTICE'));
64
+ console.log(chalk.green('Created'), path.relative(getRootDir(), 'LICENSE'));
65
+ console.log(chalk.green('Created'), path.relative(getRootDir(), 'NOTICE'));
66
+ }
67
+ }
68
+ else if (templateName === 'lib.mo') {
69
+ fs.mkdirSync(path.join(getRootDir(), 'src'), {recursive: true});
70
+ fs.copyFileSync(new URL('../templates/src/lib.mo', import.meta.url), path.resolve(getRootDir(), 'src/lib.mo'));
71
+ console.log(chalk.green('Created'), path.relative(getRootDir(), 'src/lib.mo'));
72
+ }
73
+ else if (templateName === 'lib.test.mo') {
74
+ fs.mkdirSync(path.join(getRootDir(), 'test'), {recursive: true});
75
+ fs.copyFileSync(new URL('../templates/test/lib.test.mo', import.meta.url), path.resolve(getRootDir(), 'test/lib.test.mo'));
76
+ console.log(chalk.green('Created'), path.relative(getRootDir(), 'test/lib.test.mo'));
77
+ }
78
+ else if (templateName === 'readme') {
79
+ let dest = path.resolve(getRootDir(), 'README.md');
80
+ if (fs.existsSync(dest)) {
81
+ console.log(chalk.yellow('README.md already exists'));
82
+ return;
83
+ }
84
+ fs.copyFileSync(new URL('../templates/README.md', import.meta.url), dest);
85
+
86
+ let config = readConfig();
87
+
88
+ let data = fs.readFileSync(dest).toString();
89
+ data = data.replace(/<year>/g, new Date().getFullYear().toString());
90
+ if (config.package?.name) {
91
+ data = data.replace(/<name>/g, config.package.name);
92
+ data = data.replace(/<import-name>/g, camelCase(config.package.name, {pascalCase: true}));
93
+ }
94
+ fs.writeFileSync(dest, data);
95
+
96
+ console.log(chalk.green('Created'), path.relative(getRootDir(), 'README.md'));
29
97
  }
30
98
  }
@@ -1,5 +1,3 @@
1
- type Version = text;
2
- type Ver = text;
3
1
  type User__1 =
4
2
  record {
5
3
  displayName: text;
@@ -48,7 +46,7 @@ type Result_6 =
48
46
  type Result_5 =
49
47
  variant {
50
48
  err: Err;
51
- ok: Ver;
49
+ ok: PackageVersion;
52
50
  };
53
51
  type Result_4 =
54
52
  variant {
@@ -78,6 +76,7 @@ type Result =
78
76
  type PublishingId = text;
79
77
  type PublishingErr = text;
80
78
  type PageCount = nat;
79
+ type PackageVersion = text;
81
80
  type PackageSummary__1 =
82
81
  record {
83
82
  config: PackageConfigV2__1;
@@ -186,20 +185,21 @@ service : {
186
185
  getAirdropAmount: () -> (nat) query;
187
186
  getAirdropAmountAll: () -> (nat) query;
188
187
  getApiVersion: () -> (Text) query;
189
- getDefaultPackages: (text) -> (vec record {
190
- PackageName__1;
191
- Version;
192
- }) query;
188
+ getDefaultPackages: (text) ->
189
+ (vec record {
190
+ PackageName__1;
191
+ PackageVersion;
192
+ }) query;
193
193
  getDownloadTrendByPackageId: (PackageId) ->
194
194
  (vec DownloadsSnapshot__1) query;
195
195
  getDownloadTrendByPackageName: (PackageName__1) ->
196
196
  (vec DownloadsSnapshot__1) query;
197
- getFileIds: (PackageName__1, Ver) -> (Result_6) query;
197
+ getFileIds: (PackageName__1, PackageVersion) -> (Result_6) query;
198
198
  getHighestVersion: (PackageName__1) -> (Result_5) query;
199
199
  getMostDownloadedPackages: () -> (vec PackageSummary) query;
200
200
  getMostDownloadedPackagesIn7Days: () -> (vec PackageSummary) query;
201
201
  getNewPackages: () -> (vec PackageSummary) query;
202
- getPackageDetails: (PackageName__1, Ver) -> (Result_4) query;
202
+ getPackageDetails: (PackageName__1, PackageVersion) -> (Result_4) query;
203
203
  getPackagesByCategory: () -> (vec record {
204
204
  text;
205
205
  vec PackageSummary;
@@ -212,7 +212,7 @@ service : {
212
212
  getTotalDownloads: () -> (nat) query;
213
213
  getTotalPackages: () -> (nat) query;
214
214
  getUser: (principal) -> (opt User__1) query;
215
- notifyInstall: (PackageName__1, Ver) -> () oneway;
215
+ notifyInstall: (PackageName__1, PackageVersion) -> () oneway;
216
216
  search: (Text, opt nat, opt nat) -> (vec PackageSummary, PageCount) query;
217
217
  setUserProp: (text, text) -> (Result_3);
218
218
  startFileUpload: (PublishingId, Text, nat, blob) -> (Result_2);
@@ -94,6 +94,7 @@ export interface PackageSummary__1 {
94
94
  'config' : PackageConfigV2__1,
95
95
  'publication' : PackagePublication,
96
96
  }
97
+ export type PackageVersion = string;
97
98
  export type PageCount = bigint;
98
99
  export type PublishingErr = string;
99
100
  export type PublishingId = string;
@@ -107,7 +108,7 @@ export type Result_3 = { 'ok' : null } |
107
108
  { 'err' : string };
108
109
  export type Result_4 = { 'ok' : PackageDetails } |
109
110
  { 'err' : Err };
110
- export type Result_5 = { 'ok' : Ver } |
111
+ export type Result_5 = { 'ok' : PackageVersion } |
111
112
  { 'err' : Err };
112
113
  export type Result_6 = { 'ok' : Array<FileId> } |
113
114
  { 'err' : Err };
@@ -144,8 +145,6 @@ export interface User__1 {
144
145
  'githubVerified' : boolean,
145
146
  'github' : string,
146
147
  }
147
- export type Ver = string;
148
- export type Version = string;
149
148
  export interface _SERVICE {
150
149
  'claimAirdrop' : ActorMethod<[Principal], string>,
151
150
  'finishPublish' : ActorMethod<[PublishingId], Result>,
@@ -154,7 +153,7 @@ export interface _SERVICE {
154
153
  'getApiVersion' : ActorMethod<[], Text>,
155
154
  'getDefaultPackages' : ActorMethod<
156
155
  [string],
157
- Array<[PackageName__1, Version]>
156
+ Array<[PackageName__1, PackageVersion]>
158
157
  >,
159
158
  'getDownloadTrendByPackageId' : ActorMethod<
160
159
  [PackageId],
@@ -164,12 +163,12 @@ export interface _SERVICE {
164
163
  [PackageName__1],
165
164
  Array<DownloadsSnapshot__1>
166
165
  >,
167
- 'getFileIds' : ActorMethod<[PackageName__1, Ver], Result_6>,
166
+ 'getFileIds' : ActorMethod<[PackageName__1, PackageVersion], Result_6>,
168
167
  'getHighestVersion' : ActorMethod<[PackageName__1], Result_5>,
169
168
  'getMostDownloadedPackages' : ActorMethod<[], Array<PackageSummary>>,
170
169
  'getMostDownloadedPackagesIn7Days' : ActorMethod<[], Array<PackageSummary>>,
171
170
  'getNewPackages' : ActorMethod<[], Array<PackageSummary>>,
172
- 'getPackageDetails' : ActorMethod<[PackageName__1, Ver], Result_4>,
171
+ 'getPackageDetails' : ActorMethod<[PackageName__1, PackageVersion], Result_4>,
173
172
  'getPackagesByCategory' : ActorMethod<
174
173
  [],
175
174
  Array<[string, Array<PackageSummary>]>
@@ -179,7 +178,7 @@ export interface _SERVICE {
179
178
  'getTotalDownloads' : ActorMethod<[], bigint>,
180
179
  'getTotalPackages' : ActorMethod<[], bigint>,
181
180
  'getUser' : ActorMethod<[Principal], [] | [User__1]>,
182
- 'notifyInstall' : ActorMethod<[PackageName__1, Ver], undefined>,
181
+ 'notifyInstall' : ActorMethod<[PackageName__1, PackageVersion], undefined>,
183
182
  'search' : ActorMethod<
184
183
  [Text, [] | [bigint], [] | [bigint]],
185
184
  [Array<PackageSummary>, PageCount]
@@ -4,7 +4,7 @@ export const idlFactory = ({ IDL }) => {
4
4
  const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
5
5
  const Text = IDL.Text;
6
6
  const PackageName__1 = IDL.Text;
7
- const Version = IDL.Text;
7
+ const PackageVersion = IDL.Text;
8
8
  const PackageId = IDL.Text;
9
9
  const Time = IDL.Int;
10
10
  const DownloadsSnapshot__1 = IDL.Record({
@@ -12,10 +12,9 @@ export const idlFactory = ({ IDL }) => {
12
12
  'endTime' : Time,
13
13
  'downloads' : IDL.Nat,
14
14
  });
15
- const Ver = IDL.Text;
16
15
  const FileId = IDL.Text;
17
16
  const Result_6 = IDL.Variant({ 'ok' : IDL.Vec(FileId), 'err' : Err });
18
- const Result_5 = IDL.Variant({ 'ok' : Ver, 'err' : Err });
17
+ const Result_5 = IDL.Variant({ 'ok' : PackageVersion, 'err' : Err });
19
18
  const User = IDL.Record({
20
19
  'id' : IDL.Principal,
21
20
  'emailVerified' : IDL.Bool,
@@ -145,7 +144,7 @@ export const idlFactory = ({ IDL }) => {
145
144
  'getApiVersion' : IDL.Func([], [Text], ['query']),
146
145
  'getDefaultPackages' : IDL.Func(
147
146
  [IDL.Text],
148
- [IDL.Vec(IDL.Tuple(PackageName__1, Version))],
147
+ [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion))],
149
148
  ['query'],
150
149
  ),
151
150
  'getDownloadTrendByPackageId' : IDL.Func(
@@ -158,7 +157,11 @@ export const idlFactory = ({ IDL }) => {
158
157
  [IDL.Vec(DownloadsSnapshot__1)],
159
158
  ['query'],
160
159
  ),
161
- 'getFileIds' : IDL.Func([PackageName__1, Ver], [Result_6], ['query']),
160
+ 'getFileIds' : IDL.Func(
161
+ [PackageName__1, PackageVersion],
162
+ [Result_6],
163
+ ['query'],
164
+ ),
162
165
  'getHighestVersion' : IDL.Func([PackageName__1], [Result_5], ['query']),
163
166
  'getMostDownloadedPackages' : IDL.Func(
164
167
  [],
@@ -172,7 +175,7 @@ export const idlFactory = ({ IDL }) => {
172
175
  ),
173
176
  'getNewPackages' : IDL.Func([], [IDL.Vec(PackageSummary)], ['query']),
174
177
  'getPackageDetails' : IDL.Func(
175
- [PackageName__1, Ver],
178
+ [PackageName__1, PackageVersion],
176
179
  [Result_4],
177
180
  ['query'],
178
181
  ),
@@ -194,7 +197,11 @@ export const idlFactory = ({ IDL }) => {
194
197
  'getTotalDownloads' : IDL.Func([], [IDL.Nat], ['query']),
195
198
  'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
196
199
  'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User__1)], ['query']),
197
- 'notifyInstall' : IDL.Func([PackageName__1, Ver], [], ['oneway']),
200
+ 'notifyInstall' : IDL.Func(
201
+ [PackageName__1, PackageVersion],
202
+ [],
203
+ ['oneway'],
204
+ ),
198
205
  'search' : IDL.Func(
199
206
  [Text, IDL.Opt(IDL.Nat), IDL.Opt(IDL.Nat)],
200
207
  [IDL.Vec(PackageSummary), PageCount],