@actalink/commonlib 0.0.39-dev → 0.0.40-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3186,21 +3186,36 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
3186
3186
  throw new Error("Invalid initCode");
3187
3187
  return { index, validatorInitData, useMetaFactory };
3188
3188
  };
3189
- var getPeriodInterval = (periodUnit) => {
3189
+ var getPeriodInterval = (periodUnit, currentDate = /* @__PURE__ */ new Date(), count = 1) => {
3190
+ const nextDate = new Date(currentDate);
3191
+ const c = count;
3190
3192
  switch (periodUnit) {
3191
3193
  case "5mins":
3192
- return 5 * 60;
3194
+ nextDate.setMinutes(nextDate.getMinutes() + 5 * c);
3195
+ break;
3193
3196
  case "day":
3194
- return 24 * 60 * 60;
3197
+ nextDate.setDate(nextDate.getDate() + 1 * c);
3198
+ break;
3195
3199
  case "week":
3196
- return 7 * 24 * 60 * 60;
3200
+ nextDate.setDate(nextDate.getDate() + 7 * c);
3201
+ break;
3197
3202
  case "month":
3198
- return 28 * 24 * 60 * 60;
3203
+ nextDate.setMonth(nextDate.getMonth() + 1 * c);
3204
+ break;
3205
+ case "quarter":
3206
+ nextDate.setMonth(nextDate.getMonth() + 3 * c);
3207
+ break;
3208
+ case "halfyear":
3209
+ nextDate.setMonth(nextDate.getMonth() + 6 * c);
3210
+ break;
3199
3211
  case "year":
3200
- return 365 * 24 * 60 * 60;
3212
+ nextDate.setFullYear(nextDate.getFullYear() + 1 * c);
3213
+ break;
3201
3214
  default:
3202
3215
  throw new Error("Invalid period unit");
3203
3216
  }
3217
+ const milliSeconds = nextDate.getTime();
3218
+ return { milliSeconds, nextDate };
3204
3219
  };
3205
3220
  var createBillingCheckoutSession = (serviceSessionparams) => __async(null, null, function* () {
3206
3221
  var _a, _b, _c, _d;
package/dist/index.d.cts CHANGED
@@ -5038,6 +5038,10 @@ declare class ActaAccount {
5038
5038
  }): Promise<RpcUserOperation>;
5039
5039
  }
5040
5040
 
5041
+ interface PeriodIntervalResult {
5042
+ milliSeconds: number;
5043
+ nextDate: Date;
5044
+ }
5041
5045
  declare const toSignerId: (signer: ModularSigner) => Hex;
5042
5046
  declare function toECDSASigner(signer: Signer, signerContractAddress?: `0x${string}`): Promise<ModularSigner>;
5043
5047
  declare const toPolicyId: (policies: Policy[]) => Hex;
@@ -5059,7 +5063,7 @@ declare const decodeParamsFromInitCode: (initCode: Hex, kernelVersion: KERNEL_VE
5059
5063
  validatorInitData: ValidatorInitData;
5060
5064
  useMetaFactory: boolean;
5061
5065
  };
5062
- declare const getPeriodInterval: (periodUnit: string) => number;
5066
+ declare const getPeriodInterval: (periodUnit: "5mins" | "day" | "week" | "month" | "quarter" | "halfyear" | "year", currentDate?: Date, count?: number) => PeriodIntervalResult;
5063
5067
  declare const createBillingCheckoutSession: (serviceSessionparams: {
5064
5068
  paylinkId: string;
5065
5069
  mode: "paylink";
package/dist/index.d.ts CHANGED
@@ -5038,6 +5038,10 @@ declare class ActaAccount {
5038
5038
  }): Promise<RpcUserOperation>;
5039
5039
  }
5040
5040
 
5041
+ interface PeriodIntervalResult {
5042
+ milliSeconds: number;
5043
+ nextDate: Date;
5044
+ }
5041
5045
  declare const toSignerId: (signer: ModularSigner) => Hex;
5042
5046
  declare function toECDSASigner(signer: Signer, signerContractAddress?: `0x${string}`): Promise<ModularSigner>;
5043
5047
  declare const toPolicyId: (policies: Policy[]) => Hex;
@@ -5059,7 +5063,7 @@ declare const decodeParamsFromInitCode: (initCode: Hex, kernelVersion: KERNEL_VE
5059
5063
  validatorInitData: ValidatorInitData;
5060
5064
  useMetaFactory: boolean;
5061
5065
  };
5062
- declare const getPeriodInterval: (periodUnit: string) => number;
5066
+ declare const getPeriodInterval: (periodUnit: "5mins" | "day" | "week" | "month" | "quarter" | "halfyear" | "year", currentDate?: Date, count?: number) => PeriodIntervalResult;
5063
5067
  declare const createBillingCheckoutSession: (serviceSessionparams: {
5064
5068
  paylinkId: string;
5065
5069
  mode: "paylink";
package/dist/index.js CHANGED
@@ -3149,21 +3149,36 @@ var decodeParamsFromInitCode = (initCode, kernelVersion) => {
3149
3149
  throw new Error("Invalid initCode");
3150
3150
  return { index, validatorInitData, useMetaFactory };
3151
3151
  };
3152
- var getPeriodInterval = (periodUnit) => {
3152
+ var getPeriodInterval = (periodUnit, currentDate = /* @__PURE__ */ new Date(), count = 1) => {
3153
+ const nextDate = new Date(currentDate);
3154
+ const c = count;
3153
3155
  switch (periodUnit) {
3154
3156
  case "5mins":
3155
- return 5 * 60;
3157
+ nextDate.setMinutes(nextDate.getMinutes() + 5 * c);
3158
+ break;
3156
3159
  case "day":
3157
- return 24 * 60 * 60;
3160
+ nextDate.setDate(nextDate.getDate() + 1 * c);
3161
+ break;
3158
3162
  case "week":
3159
- return 7 * 24 * 60 * 60;
3163
+ nextDate.setDate(nextDate.getDate() + 7 * c);
3164
+ break;
3160
3165
  case "month":
3161
- return 28 * 24 * 60 * 60;
3166
+ nextDate.setMonth(nextDate.getMonth() + 1 * c);
3167
+ break;
3168
+ case "quarter":
3169
+ nextDate.setMonth(nextDate.getMonth() + 3 * c);
3170
+ break;
3171
+ case "halfyear":
3172
+ nextDate.setMonth(nextDate.getMonth() + 6 * c);
3173
+ break;
3162
3174
  case "year":
3163
- return 365 * 24 * 60 * 60;
3175
+ nextDate.setFullYear(nextDate.getFullYear() + 1 * c);
3176
+ break;
3164
3177
  default:
3165
3178
  throw new Error("Invalid period unit");
3166
3179
  }
3180
+ const milliSeconds = nextDate.getTime();
3181
+ return { milliSeconds, nextDate };
3167
3182
  };
3168
3183
  var createBillingCheckoutSession = (serviceSessionparams) => __async(null, null, function* () {
3169
3184
  var _a, _b, _c, _d;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actalink/commonlib",
3
- "version": "0.0.39-dev",
3
+ "version": "0.0.40-dev",
4
4
  "author": "Actalink",
5
5
  "license": "MIT license",
6
6
  "publishConfig": {