@drawbridge/drawbridge-utils 0.0.48 → 0.0.49

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.
@@ -115,7 +115,15 @@ var cookieOptions = ({
115
115
  secure: process.env.NODE_ENV !== "development",
116
116
  ...expiresAt && { expires: new Date(expiresAt) }
117
117
  });
118
- var menuEndpoint = (type, id) => "/menu/" + type + (id ? "/" + id : "");
118
+ var menuEndpoint = (type, ...ids) => {
119
+ if (type === "campaign") {
120
+ const [organization, campaign] = ids;
121
+ return "/menu/organization/" + organization + "/campaign/" + campaign;
122
+ }
123
+ ;
124
+ const [id] = ids;
125
+ return "/menu/" + type + (id ? "/" + id : "");
126
+ };
119
127
  var scopes = [
120
128
  "profile:read",
121
129
  "profile:write",
@@ -74,9 +74,29 @@ const cookieOptions = ({
74
74
  });
75
75
 
76
76
  // Path builder for the API menu endpoints. Single source of truth for
77
- // the /menu/<type>(/<id>) shape — drawbridge-api routes and
78
- // drawbridge-app-web's ProviderLayout wrappers both read from here.
79
- const menuEndpoint = ( type, id ) => '/menu/' + type + ( id ? '/' + id : '' );
77
+ // the /menu/<...> shape — drawbridge-api routes and drawbridge-app-web's
78
+ // ProviderLayout wrappers both read from here.
79
+ //
80
+ // menuEndpoint('account') → /menu/account
81
+ // menuEndpoint('admin') → /menu/admin
82
+ // menuEndpoint('organization', orgId) → /menu/organization/abc
83
+ // menuEndpoint('campaign', orgId, campaignId) → /menu/organization/abc/campaign/xyz
84
+ // (campaign menus piggyback on the org URL prefix so the standard
85
+ // hasOrganizationAccess → hasCampaignAccess middleware chain works.)
86
+ const menuEndpoint = ( type, ...ids ) => {
87
+
88
+ if( type === 'campaign' ){
89
+
90
+ const [ organization, campaign ] = ids;
91
+
92
+ return '/menu/organization/' + organization + '/campaign/' + campaign;
93
+
94
+ }
95
+ const [ id ] = ids;
96
+
97
+ return '/menu/' + type + ( id ? '/' + id : '' );
98
+
99
+ };
80
100
 
81
101
  // ─────────────────────────────────────────────────────────────────────────
82
102
  // Scope vocabulary (locked — 15 scopes, 10 in the developer-allowed subset)
@@ -74,9 +74,29 @@ const cookieOptions = ({
74
74
  });
75
75
 
76
76
  // Path builder for the API menu endpoints. Single source of truth for
77
- // the /menu/<type>(/<id>) shape — drawbridge-api routes and
78
- // drawbridge-app-web's ProviderLayout wrappers both read from here.
79
- const menuEndpoint = ( type, id ) => '/menu/' + type + ( id ? '/' + id : '' );
77
+ // the /menu/<...> shape — drawbridge-api routes and drawbridge-app-web's
78
+ // ProviderLayout wrappers both read from here.
79
+ //
80
+ // menuEndpoint('account') → /menu/account
81
+ // menuEndpoint('admin') → /menu/admin
82
+ // menuEndpoint('organization', orgId) → /menu/organization/abc
83
+ // menuEndpoint('campaign', orgId, campaignId) → /menu/organization/abc/campaign/xyz
84
+ // (campaign menus piggyback on the org URL prefix so the standard
85
+ // hasOrganizationAccess → hasCampaignAccess middleware chain works.)
86
+ const menuEndpoint = ( type, ...ids ) => {
87
+
88
+ if( type === 'campaign' ){
89
+
90
+ const [ organization, campaign ] = ids;
91
+
92
+ return '/menu/organization/' + organization + '/campaign/' + campaign;
93
+
94
+ }
95
+ const [ id ] = ids;
96
+
97
+ return '/menu/' + type + ( id ? '/' + id : '' );
98
+
99
+ };
80
100
 
81
101
  // ─────────────────────────────────────────────────────────────────────────
82
102
  // Scope vocabulary (locked — 15 scopes, 10 in the developer-allowed subset)
@@ -61,7 +61,15 @@ var cookieOptions = ({
61
61
  secure: process.env.NODE_ENV !== "development",
62
62
  ...expiresAt && { expires: new Date(expiresAt) }
63
63
  });
64
- var menuEndpoint = (type, id) => "/menu/" + type + (id ? "/" + id : "");
64
+ var menuEndpoint = (type, ...ids) => {
65
+ if (type === "campaign") {
66
+ const [organization, campaign] = ids;
67
+ return "/menu/organization/" + organization + "/campaign/" + campaign;
68
+ }
69
+ ;
70
+ const [id] = ids;
71
+ return "/menu/" + type + (id ? "/" + id : "");
72
+ };
65
73
  var scopes = [
66
74
  "profile:read",
67
75
  "profile:write",
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "build": "tsup && npm publish"
131
131
  },
132
132
  "types": "dist/index.d.ts",
133
- "version": "0.0.48"
133
+ "version": "0.0.49"
134
134
  }