@granular-software/sdk 0.4.60 → 0.4.62

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.
@@ -12248,6 +12248,7 @@ var StateTransitionInputBindingSchema = external_exports.lazy(
12248
12248
  );
12249
12249
  var StateTransitionActionSchema = external_exports.object({
12250
12250
  effect: external_exports.string().min(1),
12251
+ providerLabel: external_exports.string().optional(),
12251
12252
  input: external_exports.record(external_exports.string(), StateTransitionInputBindingSchema).optional()
12252
12253
  }).strict();
12253
12254
  var StateTransitionAssigneeSchema = external_exports.object({
@@ -14735,6 +14736,15 @@ var stateMachineMetamodelPackage = defineMetamodelPackage({
14735
14736
  is_final: Boolean!
14736
14737
  history: [StateMachineTransitionEvent!]!
14737
14738
  instances_in_state(state: String!): [Model!]!
14739
+ instance_population(state: String!, page: Int = 1, per_page: Int = 50): StateMachineInstancePopulation!
14740
+ }
14741
+
14742
+ type StateMachineInstancePopulation {
14743
+ count: Int!
14744
+ instances: [Model!]!
14745
+ page: Int!
14746
+ per_page: Int!
14747
+ has_more: Boolean!
14738
14748
  }
14739
14749
 
14740
14750
  type StateMachineState {
@@ -14943,6 +14953,13 @@ var stateMachineMetamodelPackage = defineMetamodelPackage({
14943
14953
  value.model.target || value.model,
14944
14954
  value.name,
14945
14955
  state
14956
+ ),
14957
+ instance_population: async (value, { state, page, per_page }) => await stateMachines.instancePopulation(
14958
+ value.model.target || value.model,
14959
+ value.name,
14960
+ state,
14961
+ page,
14962
+ per_page
14946
14963
  )
14947
14964
  }
14948
14965
  };
@@ -17879,11 +17896,16 @@ var Granular = class _Granular {
17879
17896
  `${methodName}() requires at least one permission so the SDK can ensure assignments for new users.`
17880
17897
  );
17881
17898
  }
17882
- for (const profileName of user.permissions) {
17883
- const profileId = await this.ensurePermissionProfile(
17884
- sandbox.sandboxId,
17885
- profileName
17899
+ const permissionProfileIds = [];
17900
+ for (const profileReference of user.permissions) {
17901
+ permissionProfileIds.push(
17902
+ await this.ensurePermissionProfile(
17903
+ sandbox.sandboxId,
17904
+ profileReference
17905
+ )
17886
17906
  );
17907
+ }
17908
+ for (const profileId of permissionProfileIds) {
17887
17909
  await this.ensureAssignment(
17888
17910
  user.granularId,
17889
17911
  sandbox.sandboxId,
@@ -18888,25 +18910,37 @@ var Granular = class _Granular {
18888
18910
  }
18889
18911
  }
18890
18912
  /**
18891
- * Ensure a permission profile exists for a sandbox, creating it if needed.
18892
- * If profileName matches an existing profile name, returns its ID.
18893
- * Otherwise, creates a v1 source-profile file shape with an allow default.
18913
+ * Resolve an existing permission profile by exact name or ID.
18914
+ *
18915
+ * `allow-all` is the sole compatibility profile that the SDK may provision
18916
+ * automatically. Every other missing reference fails closed so a typo or
18917
+ * untrusted role value cannot become an allow-default profile.
18894
18918
  */
18895
- async ensurePermissionProfile(sandboxId, profileName) {
18896
- try {
18897
- const profiles = await this.permissionProfiles.list(sandboxId);
18898
- const existing = profiles.find((p) => p.name === profileName);
18899
- if (existing) {
18900
- return existing.permissionProfileId;
18901
- }
18902
- } catch {
18919
+ async ensurePermissionProfile(sandboxId, profileReference) {
18920
+ const normalizedReference = typeof profileReference === "string" ? profileReference.trim() : "";
18921
+ if (!normalizedReference) {
18922
+ throw new Error(
18923
+ "Permission profile references must be non-empty names or IDs."
18924
+ );
18925
+ }
18926
+ const profiles = await this.permissionProfiles.list(sandboxId);
18927
+ const existing = profiles.find(
18928
+ (profile) => profile.name === normalizedReference || profile.permissionProfileId === normalizedReference
18929
+ );
18930
+ if (existing) {
18931
+ return existing.permissionProfileId;
18932
+ }
18933
+ if (normalizedReference !== "allow-all") {
18934
+ throw new Error(
18935
+ `Permission profile "${normalizedReference}" was not found in sandbox ${sandboxId}. Provision it with granular build or granular deploy before calling openEnvironment(). Only the reserved "allow-all" profile can be created automatically.`
18936
+ );
18903
18937
  }
18904
18938
  const created = await this.permissionProfiles.create(sandboxId, {
18905
- name: profileName,
18939
+ name: normalizedReference,
18906
18940
  rules: {
18907
18941
  schemaVersion: 1,
18908
- name: profileName,
18909
- description: profileName === "allow-all" ? "Every declared action is visible unless a manifest policy denies it." : `Generated permission profile ${profileName}`,
18942
+ name: normalizedReference,
18943
+ description: "Every declared action is visible unless a manifest policy denies it.",
18910
18944
  defaults: { actionPolicy: "allow" },
18911
18945
  actions: []
18912
18946
  }