Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : SPB Git for iOS and iPadOS8 * File : scripts/portal/asc-record.js9 * Module : Scripts10 * Repository : https://git.spboucher.ai/spbgit-ios11 * Project Website : Not specified12 * Created : 2026-12-0213 * Last Modified : 2026-12-0214 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : None specified (no license file in this repository)34 *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// App Store Connect: create the app record for ai.spboucher.git when it is missing (idempotent).44async function main(){45 const bundleId='ai.spboucher.git', sku='spbgit-ios-001', names=['SPB Git','SPB Git Mobile','SPB Git — Forge','SPB Git for iOS'];46 let r=await fetch('/iris/v1/apps?filter[bundleId]='+bundleId+'&fields[apps]=name,bundleId,sku',{credentials:'include'});47 if(r.status>=300) return 'LIST FAIL '+r.status+' (session?)';48 let j=await r.json(); const ex=(j.data||[]).filter(a=>a.attributes.bundleId===bundleId);49 if(ex.length) return 'EXISTS id='+ex[0].id+' name='+ex[0].attributes.name+' sku='+ex[0].attributes.sku;50 for(const name of names){51 const body={data:{type:"apps",attributes:{sku,primaryLocale:"fr-CA",bundleId},relationships:{appStoreVersions:{data:[{type:"appStoreVersions",id:"${store-version-ios}"}]},appInfos:{data:[{type:"appInfos",id:"${new-appInfo-id}"}]}}},52 included:[{type:"appStoreVersions",id:"${store-version-ios}",attributes:{platform:"IOS",versionString:"1.0.0"},relationships:{appStoreVersionLocalizations:{data:[{type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}"}]}}},53 {type:"appStoreVersionLocalizations",id:"${new-appStoreVersionLocalization-id}",attributes:{locale:"fr-CA"}},54 {type:"appInfos",id:"${new-appInfo-id}",relationships:{appInfoLocalizations:{data:[{type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}"}]}}},55 {type:"appInfoLocalizations",id:"${new-appInfoLocalization-id}",attributes:{locale:"fr-CA",name}}]};56 r=await fetch('/iris/v1/apps',{method:'POST',credentials:'include',headers:{'Content-Type':'application/json','X-Csrf-Itc':'[asc-ui]'},body:JSON.stringify(body)});57 const t=await r.text();58 if(r.status<300){ const k=JSON.parse(t); return 'CREATED id='+k.data.id+' name='+name+' sku='+sku; }59 const msg=(()=>{try{return JSON.stringify(JSON.parse(t).errors.map(e=>[e.code,e.detail]))}catch(e){return t.slice(0,300)}})();60 if(!/name|NAME/.test(msg)||names.indexOf(name)===names.length-1) return 'FAIL '+r.status+' '+msg;61 }62}63