SPB Git

Repository Public MIT

asc-create-app.js 3.4 KB 61 lines javascript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : ORIX Astra8 * File             : Scripts/asc-create-app.js9 * Module           : Scripts10 * Repository       : https://git.spboucher.ai/orix-astra11 * Created          : 2026-11-2212 * Last Modified    : 2026-11-2213 *14 * Author           : Simon-Pierre Boucher15 * Position         : Professor of Finance16 * Institution      : Université du Québec en Outaouais (UQO)17 * Organization     : SP Boucher18 * Website          : https://spboucher.ai19 * Git              : https://git.spboucher.ai20 *21 * Preferred Contact: support@spboucher.ai22 * Development      : dev@spboucher.ai23 * Support          : support@spboucher.ai24 * Security/Admin   : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License          : Proprietary, all rights reserved (see license file)33 * License File     : LICENSE34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243// Creates the App Store Connect record for ORIX Astra through the signed-in Safari session (the public API cannot create a record).44// Run with: Scripts/asc-safari.sh Scripts/asc-create-app.js45async function create(bundleId, sku, names) {46  for (const name of names) {47    const body = {data:{type:"apps",attributes:{sku, primaryLocale:"en-CA", bundleId},48      relationships:{appStoreVersions:{data:[{type:"appStoreVersions",id:"${store-version-ios}"}]},appInfos:{data:[{type:"appInfos",id:"${new-appInfo-id}"}]}}},49      included:[{type:"appStoreVersions",id:"${store-version-ios}",attributes:{platform:"IOS",versionString:"1.0.0"},relationships:{appStoreVersionLocalizations:{data:[{type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}"}]}}},50        {type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}",attributes:{locale:"en-CA"}},51        {type:"appInfos",id:"${new-appInfo-id}",relationships:{appInfoLocalizations:{data:[{type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}"}]}}},52        {type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}",attributes:{locale:"en-CA",name}}]};53    const r = await fetch('/iris/v1/apps',{method:'POST',credentials:'include',headers:{'Content-Type':'application/json','X-Csrf-Itc':'[asc-ui]'},body:JSON.stringify(body)});54    const t = await r.text();55    if (r.status < 300) { const j = JSON.parse(t); return bundleId+' OK id='+j.data.id+' name='+name; }56    const msg = (()=>{try{return JSON.stringify(JSON.parse(t).errors.map(e=>[e.code,e.detail,e.source]))}catch(e){return t.slice(0,400)}})();57    if (!/name|NAME/.test(msg) || names.indexOf(name) === names.length-1) return bundleId+' FAIL '+r.status+' '+msg;58  }59}60async function main(){ return await create('ai.spboucher.orix.astra','orixastra-ios-001',['ORIX Astra','ORIX Astra AI','ORIX Astra Studio']); }61
Files main
Menu

Theme